tags:

views:

81

answers:

2

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?

+3  A: 

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

CMS
Thanks :) I hope you aren't offended if I give the answer to nall… He seems to need the rep a *little* more ;)
David Wolever
marks and registers are different, register A is not the same as mark A... in fact, there is no register 'A', yanking to register A will append the yanked text to register 'a' instead.
Shrikant Sharat
@sharat87: you are right, rephrased my answer...
CMS
+4  A: 

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.

nall
Awesome, thanks :)
David Wolever