Thursday, July 26, 2007

Tip: Poor man's text bookmarking

Many IDEs and text editors support a “bookmarking” feature, which will let you set a bookmark at a particular line of code or location in a document (generally through a menu pick or a shortcut key, which will bring up a prompt to enter a name for the bookmark), and then return there later (generally either through a dialog which allows you to pick a bookmark that you set previously, or though a Go To Next Bookmark / Go To Previous Bookmark shortcut key).

However, there currently isn’t any standard convention among Windows applications for the shortcut keys and menu options that are used to set and navigate to bookmarks. Visual Studio 2005, Eclipse 3.2.1, and Word 2003 (to name three applications that support mid-document bookmarking) all use completely different methods for setting and accessing bookmarks.

I’ve come up with my own trick for setting temporary bookmarks in a document. When I’m at a place at a document that I want to easily be able to return to a little bit later, I enter the string $$$ in the document. (If I’m writing code, I’ll enter it as a comment so that the code will still compile.) Then, later, I just use the editor’s Find feature to search for the $$$ to return that spot. When I’m done working with that area of the document, I delete the $$$. It’s also easy to do a multi-file search for “$$$” to find and remove any bookmarks that I might have set and then forgotten to clean up (prior to checking in a set of code changes, for example).

I chose the string “$$$” because it doesn’t tend to appear anywhere else in the types of documents that I work with, so when I go back and search for "$$$" later, my bookmark is the only match. It's also easy to type and easy to remember.

This technique is nice because it can be used in any text editor, regardless of the particular editor’s own convention for accessing bookmarks. As a sort of poor man's bookmark, it can be used even in editors that do not support bookmarking at all.

1 comment:

  1. me too Jon -- i use this kind of technique for navigating text documents all the time. in big docs i sometimes put a table of contents too -- wherein you can use the heading in the TOC to search for the actual section in the text file.

    lb (secretGeek.net)

    ReplyDelete

Non-spammers: Thanks for visiting! Please go ahead and leave a comment; I read them all!

Attention SPAMMERS: I review all comments before they get posted, and I REPORT 100% of spam comments to Google as spam! Why not avoid getting your account banned as quickly -- and save us both a little time -- by skipping this comment form and moving on to the next one on your list? Thanks, and I hope you have a great day!