vimtricks.wiki Concise Vim tricks, one at a time.

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

  • ma sets mark a at the current cursor position (line and column)
  • `a jumps to the exact line and column of mark a
  • 'a jumps to the beginning of the line (first non-blank character) where mark a was 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
  • `a places the cursor on the r in World (line 1, column 9)
  • 'a places the cursor on the H in Hello (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`a deletes from the cursor to the exact mark position, while d'a deletes 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 ' \`` and nnoremap ` '`
  • Uppercase marks (A-Z) work across files — jumping to `A will switch buffers if needed, landing on the exact position in the other file

Next

How do I edit multiple lines at once using multiple cursors in Vim?