home *** CD-ROM | disk | FTP | other *** search
-
- // ───────────────────────────────────────────────────────────────────
- // The Aurora Editor v2.0
- // Copyright 1993-1995 nuText Systems. All Rights Reserved Worldwide.
- //
- // Delete blank lines in a file or block
- //
- // This macro deletes blank lines in the current edit window. The
- // operation is confined to a marked block if one exists.
- //
- // (Note: this macro will run faster if undo is disabled)
- // ───────────────────────────────────────────────────────────────────
-
- include bootpath "define.aml"
-
- var count
-
- // test for edit windows
- if not wintype? "edit" then
- msgbox "Edit windows only!"
- return
- end
-
- // test if a marked block exists in the current file
- block_count = mark? and getmarkbuf == getcurrbuf
-
- // display message
- say "Deleting blank lines" + (if? block_count " in block") + "..."
-
- // set search options
- options = "x*" + (if? block_count 'b')
-
- // save cursor position and goto first line
- pushcursor
- gotopos 1 (if? block_count (getmarktop) 1)
-
- // mark the beginning of an undoable group of operations
- undobegin
-
- // search for blank lines using regular expressions
- while find "^ *$" options do
- delline
- count = count + 1
- end
-
- // mark the end of an undoable group of operations
- undoend
-
- // restore cursor
- popcursor
-
- // clear the title bar
- display
-
- // display the word count
- shortbox (if? count (thousands count) "No") + " lines deleted" +
- (if? block_count " in the block")
-
-