I’ve been using “vi” (a popular unix text editor) for about 15 years. Today I learned something important. Vi has bookmarks that can be used for doing stuff with blocks of text easily.

You mark a bookmark by typing: ma

Where a is the name of the bookmark. Apparently you can have one for each key. Then, you can do stuff with those bookmarks by typing: 'a

By itself, that jumps you to the bookmark you just made.

It gets useful when you want to do something like indent a block of text in vi. First you mark one end of the block of text with ma Then, you move your cursor to the other end of the block of text and type >'a It automatically indents the entire block. You can start with either the bottom or the top and it will work.

For 15 years I have been actually counting lines to cut, copy and indent blocks of text in vi. I can blame this in part to having gvim available about 80% of the time…but sometimes you don’t have gvim handy and need to do this stuff.

Close Menu