It depends on configuration setting Bookmark column with line
available since UE v12.20 and UES v6.00 to which column the caret is set on execution of PreviousBookmark
command. If this setting is not enabled, the caret is always set to beginning of the bookmarked line. But if this setting is enabled, the caret is positioned on the column the caret was on setting the bookmark.
You are correct that my initial macro has not cleared all bookmarks if
- The file ends with a line termination and a bookmark was set at end of file (on the blank line at bottom).
- The file does not have a line termination at end, and Bookmark column with line is enabled, and the bookmark was set as caret was at end of file.
In both cases the macro exited after clearing all bookmarks except the bookmark at end of file. A bookmark at end of file is removed now also with the green highlighted macro code added to the macro code in my first post.
Daemon, your solution works usually also, but always modifies the file which is not good and of course fails on a read-only file.
I could also reproduce the endless loop. If setting Bookmark column with line
is not enabled and the file does not end with a line termination and command PreviousBookmark
is executed with no bookmark present anymore UltraEdit v18.104.22.1680 moves the caret to beginning of the last line. This was an unexpected behavior for me and is in my point of view definitely not correct. The caret should not be moved if a goto bookmark command is executed, but there is no bookmark set. It looks like UltraEdit is moving always first the caret to start of current line and then jumps to the bookmarked line which fails if there is no line bookmarked anymore. A better behavior would be first to check if the bookmark to jump exists and only if this is the case, the caret should be moved to start of the bookmarked line. I reported this issue by email to IDM support and IDM rated it as a wrong behavior.
I found a workaround for above described issue of UltraEdit by inserting twice the command Key END
highlighted in my previous post with red color as you, Daemon, have done too.
There is now just one problem left. If the active file is completely empty and no bookmark is set, execution of the macro results in setting a bookmark. But I expect that nobody runs this macro on an empty file with no bookmark set.