KMCG

Global Marks

Thursday, July 7, 2016 A.D.

So last time I talked about how helpful marks are. It's true, they are super helpful, but did you think at any point that marks left something to be desired? Maybe you'd like them to persist from one vim session to the next. Maybe, instead of having marks be confined to a particular buffer, you'd like to use a single set of marks across all of your files.

I am going to make your dreams come true.

Marks set with a capital letter will behave differently than those set with a lowercase letter in the following ways:

  • They are global. Each mark will only point to a single location in a single file across your entire filesystem
  • They persist betweem vim sessions (by default)

So, what are they good for? I use them to quickly open files that exist in only one place. For example, I have the mark V set to the first line of my .vimrc file. I'm sure there are better, more advanced uses, but I am a simple man.

Next time on The Young Person's Guide to Vim, we will look at some of the marks that vim sets for you automatically, as well as the two different ways of jumping to a mark's location.