by Mofi » Mon Nov 24, 2008 8:13 am
The following macro works on your small example.
It first cuts all lines starting with not an uppercase character and collects them in clipboard 9.
Next it cuts all lines starting with an uppercase character and the second character is not an uppercase character and collects them in clipboard 8.
The remaining lines are those starting with 2 uppercase characters and empty lines. These lines are now sorted.
The cutted lines starting with an uppercase character, but second character is not an uppercase character are pasted now from clipboard 8 into a new file, sorted and copied back into the source file below the already sorted lines (more or less) completely in uppercase.
Same procedure is done next with the lines in clipboard 9 which do not start with an uppercase character. The new file is closed without saving.
The result is what you asked for. I just can hope it works also for your huge files. That depends on how large your file really is and how much RAM you have to hold all the data in the clipboards.
The macro property Continue if a Find with Replace not found or Continue if search string not found must be checked for this macro.
InsertMode
ColumnModeOff
HexOff
UnixReOff
Bottom
IfColNumGt 1
"
"
EndIf
Top
Clipboard 9
ClearClipboard
Loop
Find MatchCase RegExp "%[~A-Z^p]*^p"
IfFound
CutAppend
Else
ExitLoop
EndIf
EndLoop
Top
Clipboard 8
ClearClipboard
Loop
Find MatchCase RegExp "%[A-Z][~A-Z^p]*^p"
IfFound
CutAppend
Else
ExitLoop
EndIf
EndLoop
Top
SortAsc 1 -1 0 0 0 0 0 0
NewFile
Paste
Top
SortAsc 1 -1 0 0 0 0 0 0
SelectAll
Cut
NextWindow
Bottom
Paste
ClearClipboard
Clipboard 9
PreviousWindow
Paste
Top
SortAsc 1 -1 0 0 0 0 0 0
SelectAll
Copy
CloseFile NoSave
Paste
ClearClipboard
Clipboard 0