replace words from begin of file until cursor position

replace words from begin of file until cursor position

2
NewbieNewbie
2

    Jan 20, 2005#1

    Is it posible, to get a macro for replace all words which are selected. But only from start of file until cursers place?

    Thanks for helping!

    46
    Basic UserBasic User
    46

      Jan 20, 2005#2

      Hello stadi,

      I'm sure that's not the best way to do it, but it seems to work:

      Code: Select all

      InsertMode
      ColumnModeOff
      HexOff
      UnixReOn
      Clipboard 9
      IfSel
        Copy
        Key LEFT ARROW
        Key RIGHT ARROW
        "~@#"
        Top
        GetString "Replace by:"
        "~@@#
        "
        StartSelect
        Find Select "~@#"
        Find "^c"
        Replace All SelectText "~@r#"
        EndSelect
        Top
        Find RegExp "(.*)~@@#"
        Replace "\1"
        Top
        StartSelect
        Key END
        EndSelect
        Cut
        Delete
        Find "~@r#"
        Replace All "^c"
        Top
        Find "~@#"
        Delete
      EndIf
      Clipboard 0
      Don't be affraid by the code it's quite simple:

      1) Copy in the clipboard 9 the selected part (if any, else do nothing)
      2) Mark current position (~@#)
      3) Go to the top and ask for replacement string and mark its end (~@@#)
      4) Select text until the original position
      5) Replace, in the selection, the content of the clipboard by an UNIQUE pattern (~@r#)
      6) Go to the top and copy in clipboard the replacement string
      7) Replace, in the whole text, the unique pattern by the content of the clipboard
      8) Go back to the original position

      Hope can help you.
      Never forget: "Above the clouds, The sky is blue and the sun shine"

      2
      NewbieNewbie
      2

        Jan 21, 2005#3

        merci palou,
        il fonctionne tres bien.