Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vim: create marks across files?

Tags:

vim

A feature I often use in Vim is mark and jump-to-mark (')… But they only work within a file.

Is there any way to create a mark which works across files? For example, so I can create mark a on line 42 of foo.py, then jump to that mark while I'm editing bar.py?

like image 799
David Wolever Avatar asked Oct 17 '09 05:10

David Wolever


People also ask

How do I create a mark in Vim?

Setting marks To set a mark, type m followed by a letter. For example, ma sets mark a at the current position (line and column). If you set mark a, any mark in the current file that was previously identified as a is removed. If you set mark A, any previous mark A (in any file) is removed.

Where are vim marks stored?

Marks are stored in viminfo not in a session and the viminfo file is only written when exiting vim.

How do I remove a mark in Vim?

You can delete marks with the :delm command. To delete marks `a , `e , and `G , you would type :delm aeG . You can delete all local marks with :delm! .


2 Answers

Yes. Use capital letters for the mark.

http://vim.wikia.com/wiki/Using_marks

Marks can span across files. To use such marks one has to use upper-case registers i.e. A-Z. Lower-case registers are used only within files and do not span files. That's to say, if you were to set a mark in a file foo.c in register "a" and then move to another file and hit 'a, the cursor will not jump back to the previous location. If you want a mark which will take you to a different file then you will need to use an upper-case register. For example, use mA instead of ma.

like image 118
nall Avatar answered Sep 25 '22 03:09

nall


Use the A-Z marks, they are available across files.

like image 24
Christian C. Salvadó Avatar answered Sep 25 '22 03:09

Christian C. Salvadó