What is the difference between backtick and single quote when jumping to marks?
Answer
` vs '
Explanation
Vim offers two ways to jump to a mark, and the difference is crucial: the backtick (`) jumps to the exact line and column where the mark was set, while the single quote (') jumps to the first non-blank character on the marked line. Mastering this distinction lets you return to precisely the right spot every time.
How it works
masets markaat the current cursor position (line and column)`ajumps to the exact line and column of marka'ajumps to the beginning of the line (first non-blank character) where markawas set- This distinction applies to all marks: named marks (
a-z,A-Z), automatic marks (`.,`',`"), and more
Example
Given the text, you set a mark with ma while the cursor is on the r in World:
Hello World
Foo Bar
`aplaces the cursor on therinWorld(line 1, column 9)'aplaces the cursor on theHinHello(line 1, column 1 — the first non-blank character)
The same applies to special marks. After making a change on column 15 of line 10:
`.jumps to line 10, column 15 (exact last change position)'.jumps to line 10, first non-blank character
Tips
- Use backtick (
`) when you need column-precise jumps — returning to the exact cursor position in a line of code - Use single quote (
') when you only care about the line — scrolling back to a section of the file - The most useful automatic marks with both forms:
`./'.— position of last change`"/'"— position when the file was last closed`[/'[— start of last yank or change`]/']— end of last yank or change
- Both forms work as motions with operators:
d`adeletes from the cursor to the exact mark position, whiled'adeletes whole lines from the cursor's line to the mark's line - If you find backtick hard to reach, some users swap them in their vimrc:
nnoremap ' \`` andnnoremap ` '` - Uppercase marks (
A-Z) work across files — jumping to`Awill switch buffers if needed, landing on the exact position in the other file