how to keep a selected text, after a replace ?

how to keep a selected text, after a replace ?

8
NewbieNewbie
8

    Nov 01, 2005#1

    hello,

    i have a macro who "upgrade" my html headers : p to h1, h1 to h2, h2 to h3 etc...
    Another one to "downgrade" them.

    I make a simple "find and replace Selected text".

    It 's working, but i want to be able to keep the selected text to run my macro multiple times...

    ex : select "<h1>titre</h1>", call 3 times my macro and have "<h4>titre</h4>" (without re-select after each call).

    thanks

    344
    MasterMaster
    344

      Nov 01, 2005#2

      Hi neekolo

      You have to memory the position yourself.
      Do the following trick in a macro:
      1. cut out selection
      2. Type "$X%" (or something else unique) for your marker as position
      3. Mark the line and cut it out
      4. take line to a new document and replace h1 with h2, h2 with h3 etc....
      6. cut it out, close new document and paste back line
      7. replace $X% with selection in 1 (^c, you have clipboard 1-9)

      Should work

      rds Bego
      Normally using all newest english version incl. each hotfix. Win 10 64 bit

      8
      NewbieNewbie
      8

        Nov 03, 2005#3

        cool!
        thank you Bego.

        It's working. There is only a 'display' problem, when the marker text replace the true one. the window move up & down. That's a small problem.

        I've tested to keep the original text displayed to avoid the move, but i've a problem :

        Code: Select all

        Copy 
        NewFile
        Paste 
        SelectAll
        Find "h1>"
        Replace All SelectText "h2>"
        Clipboard 8
        Cut 
        CloseFile NoSave
        Clipboard 9
        Find Up "^c"
        Find "^c"
        Clipboard 8
        Replace All SelectText "^c"
        
        at the two last lines : the "clipboard 8" is not possible here, "Replace" must be just after the "Find".

        Is there any way to "find" the content of one clipboard and "replace" it by the content of another (without marker...) ?

        344
        MasterMaster
        344

          Nov 04, 2005#4

          Hi neekolo,

          You can be helped :wink:

          - You can forget about switching Clipboard.
          Here I use 9 for the macro and go back to User-default at the end
          - Instead of copying, use cut
          - Use find backward to "<h" to reselect your text:

          Code: Select all

          InsertMode
          ColumnModeOff
          HexOff
          UnixReOff
          Clipboard 9
          Cut 
          NewFile
          Paste 
          Key HOME
          Find "h3"
          Replace All "h4"
          Find "h2"
          Replace All "h3"
          Find "h1"
          Replace All "h2"
          SelectAll
          StartSelect
          Cut 
          CloseFile NoSave
          Paste 
          Find Up Select "<h"
          Clipboard 0
          
          Thanks to the master called Mofi here who explained me the functionality of find select .... :wink:

          Tell me if it worked.

          rds Bego :D
          Normally using all newest english version incl. each hotfix. Win 10 64 bit