How do I set marks that work across files?
Answer
m{A-Z}
Explanation
Uppercase marks (A-Z) are global marks that remember both the file and the cursor position. Jumping to a global mark will open the file if it is not already loaded.
How it works
mAsets global markAat the current position and file'Ajumps to markA, opening the file if necessary`Ajumps to the exact line and column
Example
While editing src/main.go at line 42, press mM. Later, while editing src/utils.go, press 'M to jump back to line 42 in main.go.
Tips
- Global marks persist across Vim sessions if
viminfo/shadais configured - You have 26 global marks (A-Z)
:marksshows all marks including globals:delmarks Adeletes mark A- Useful for bookmarking frequently visited files in a project