Hownow wrote:What does the search & replace for the same string accomplish?
It does nothing or exactly in your case without Find option MatchCase it converts the word trade in any case to "Trade". It's just for testing if a specific string is within the current line. It simply restricts the find on a single line.
I guess your loop is not working because there is missing the command EndLoop. And in the IfNotFound branch you have forgotten
EndSelect
Key UP ARROWbefore Key END. SelectLine selects the whole line including the line terminator and the cursor is at start of the next line.
If you are a macro beginner you should test your macro step by step by inserting the macro command ExitMacro after every important command sequence and look what happens when executing the macro to this point. Then reload the file to restore all changes, edit the macro and move the ExitMacro command down, run the macro again, look again, reload the file, ...
But I think for your problem there is a much faster solution.
InsertMode
ColumnModeOff
HexOff
TrimTrailingSpaces
Top
StartSelect
Find Select "Trade"
IfSel
Key UP ARROW
Key END
Find "^p"
Replace All SelectText " "
EndIf
EndSelect
Top
What this macro does?
From top of the file it selects everything till word "Trade". If the word "Trade" (or "trade" or "tRaDe" or ...) is found and so a selection exists, it removes from the selection the current line by setting the cursor to the end of the previous line (or current line if "Trade" is found at first line of the file). Because of the StartSelect command all cursor moves modify the selection until EndSelect is used. Then it replaces in the whole selected text all CRLF by a space to concatenate the lines. If your file is a Unix file opened in Unix mode you have to use ^n instead of ^p.
I'm not sure if the line with "Trade" should be also added to the concatenate block or not. The macro above will not add it. Remove the macro commands
Key UP ARROW
Key ENDand the text of the line with "Trade" is at the end of the single line after the macro execution.