Trick to easily bookmark one or several range(s) of lines, in the current file

  • Hi, All,

    If you need to bookmark one or more bunch(s) of consecutive lines, all at once, here is my trick :

    • First put any number of consecutive # symbol(s) at the end of, both, the first and last lines to be bookmarked

    • Repeat this action for any other range of lines, which needs bookmarking

    • Use the Mark dialog and search a specific regular expression

    So, here is the road map, with a recent N++ release :

    • Put, for instance, the string ### at the end of a first line to be bookmarked

    • Put an other string ### at the end of a last line to be bookmarked

    • Repeat these two points above, for any range of lines, which needs bookmarking ( any number of # symbols is valid )

    • Now, open the Mark dialog ( Edit > MArk... ) I personally mapped the Ctrl + M to the Mark dialog !

    • SEARCH #+$(?s).+?#+$

    • Tick the Bookmark line, Purge for each search and Wrap around options

    • Untick the Backward direction options, if necessary

    • Select the Regular expression search mode

    • Click on the Mark All button

    Voilà !

    • Now, untick the Bookmark line option ( IMPORTANT )

    • Click on the Clear all marks, again, to delete the red highlighting => Only the bookmarks remain visible

    • Eventually, you may remove all these # symbols, at end of lines, with the simple regex S/R :

    SEARCH #+$


    Best Regards,


    P.S. :

    On reflection, I’d say that it would be nice if, after an Edit > Begin/End Select action, a Ctrl + F2 would bookmark / unbookmark all the lines of that selection !

    Of course, in case of a normal selection, a Ctrl + F2 action would just bookmark, as now, the last line of the selection

  • @guy038 said in Trick to easily bookmark one or several range(s) of lines, in the current file:

    Tick the … Wrap around option
    Untick the Backward direction option

    My experience has shown that, any time the Wrap around checkbox is ticked, the state of the Backward direction checkbox is meaningless.

  • Hi, @alan-kilborn and All,

    Alan, thanks for this information ! I rarely use the backward direction and rather with normal search mode !

    Indeed, when the Wrap around option is ticked, a click on buttons :

    • Find All in Current Document

    • Replace All

    • Mark All

    processes current file from beginning to end of file, whatever the state of the Baskward direction option

    However, a click on buttons :

    • Find Next

    • Replace

    does depend on the state of the two independent options Backward direction and Wrap around

    As for the other buttons :

    • Find All in All Opened Documents

    • Replace All in All Opened Documents

    • Find All

    • Replace in Files

    obviously, they act on the scanned files, from beginning to end, independently of the state of the options Backward direction and/or Wrap around !



  • @guy038

    I was a little loose with my “any time” verbage. Your context was the Mark operation, which was what I meant, but said poorly.

Log in to reply