What is the difference between ' and ` when jumping to a mark in Vim?
Answer
' vs `
Explanation
Vim provides two distinct ways to jump to a mark, and they behave differently: the apostrophe ' jumps to the first non-blank character of the marked line, while the backtick ` jumps to the exact cursor position where the mark was set. This distinction matters when you care about column position, not just line.
How it works
'a— jumps to the beginning of the line containing marka`a— jumps to the exact line and column where markawas set- The same applies to all marks: lowercase
a–z, uppercaseA–Z, and special marks like`.(last change) or`[(start of last yank)
Example
Given this file, with mark a set on the w of world:
hello world
^
mark a set here (column 6)
'amoves the cursor to column 0 (first non-blank of the line)`amoves the cursor to column 6 (exact mark position)
Tips
- Use
`(backtick) in operator commands for precise text objects:d`adeletes from the cursor to the exact position of marka, whiled'adeletes from cursor to the start of the line - Special mark
`.jumps to the exact position of the last change; use'.to jump to the line of the last change instead - Lowercase marks (
a–z) are file-local; uppercase marks (A–Z) work across files