Vim

Vim: Marks

Marks enable you to remember a location in a buffer or file so you can quickly jump back to it.

Local marks are specific to the current file and are indicated by lowercase characters. Global marks can be across any files and are indicated by uppercase characters.

Setting marks:

Local marks are lost when the file is removed from the buffer list. Local marks can be used with operators.

Global marks include the filename and can be used to jump to another file. These are remembered across Vim sessions. Global marks can only be used as motions if they are defined in the file that the current buffer is displaying.

You can move to a mark with either the backtick or single quote characters:

A mark is not visible in any way.

:marks list all marks,

Marks are independent from registers (these two concepts are often confused).

Numbered Marks

Marks {0-9} are used to indicate the location of the cursor the last time you exited vim. 0 is the location the very last time you exited Vim, 1 the time before that and so on. These marks can not be manually set.

Special Marks

Remember that ` jumps to the actual cursor position and ' jumps to the first non-blank character on the target line.

There are more special marks.

Do I Use Marks?

I have never been a big user of marks, but there are a couple of use cases that do work for me.

The first is using `0 to jump to where I left off the last Vim session. This can save some time if you’re not quite in the groove yet.

The second is if I’m spending a lot of time in a particular code base it can be useful to associate commonly referenced files with an uppercase mark. Even then, I mostly use something like CtrlP to jump around the code base.

So, I guess marks are good to know about, but I don’t use them much.

If there was a plugin that displays marks, perhaps in the gutter, that might be useful (but, I have never bothered to look).

Resources

:help mark

:help mark-motions

Tools

Web

Languages

Data