How do I jump to a mark without adding my current position to the jumplist?
Answer
g'{mark}
Explanation
Vim's standard mark-jump commands ('a, `a) always add the current position to the jumplist before leaping to the mark. This means a <C-o> afterward brings you back — but it also means repeated mark-jumping can flood your jumplist with intermediate positions. The g' and g` variants jump to marks without recording the current position in the jumplist, keeping it clean.
How it works
'{mark}— jump to the first non-blank of the mark's line; adds current position to jumplist`{mark}— jump to the exact mark position (line and column); adds current position to jumplistg'{mark}— jump to first non-blank of the mark's line; does NOT modify the jumplistg`{mark}— jump to the exact mark position; does NOT modify the jumplist
Example
You have marks a and b set in two different locations. You want to peek at mark a and jump back without affecting your <C-o> / <C-i> history:
1. Use g'a → jumps to mark a (jumplist unchanged)
2. Use g'b → jumps to mark b (jumplist unchanged)
3. Press <C-o> → goes back to wherever you were before all of this
With plain 'a, step 3 would only take you back to mark b, not to the original position before you started jumping between marks.
Tips
- Especially useful in scripts and mappings where you want non-intrusive mark navigation
- Combine with
:keepjumps {cmd}to prevent any jump command in a sequence from modifying the jumplist - View the current jumplist with
:jumps - The special marks
g'<andg`</g'>andg`>jump to the boundaries of the last visual selection without polluting jumplist history