2008-07-17

Visually seeing all (book)marks in Vim

I attended a friend's masters thesis defense (congrats, Ducky!) and it made me think about bookmarks in editors. For TextMate, it has a simple bookmark feature: press Cmd-F2 to leave one, and then cycle forwards or backwards through them. Vim, on the other hand, has bookmarks labeled by letter, which can be per-file or global.

With TextMate's solution it is quick to set a mark and requires no thinking. The problem, though, is you have to cycle through the bookmarks blindly until you find the one you want. That can be annoying if you are leaving marks behind when you are jumping around following control flow through various methods and classes.

Vim has the opposite problem. You have to assign a bookmark that has not been used previously, but it does allow you to jump directly to marks. If you run the ``:marks`` command you get a list of every mark currently set, complete with line/column/text info. So if you know you set a mark but not sure which one exactly, you can try to do it based on what text is on that line. You can also jump directly back to another file if you set a global mark there, allowing you to track your movement between files. So you trade off the ease-of-use of just leaving any random mark for the ability to be specific and get a list of all known marks.