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

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 mark a
  • `a — jumps to the exact line and column where mark a was set
  • The same applies to all marks: lowercase az, uppercase AZ, 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)
  • 'a moves the cursor to column 0 (first non-blank of the line)
  • `a moves the cursor to column 6 (exact mark position)

Tips

  • Use ` (backtick) in operator commands for precise text objects: d`a deletes from the cursor to the exact position of mark a, while d'a deletes 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 (az) are file-local; uppercase marks (AZ) work across files

Next

How do I match a pattern only when it is preceded or followed by another pattern, without including that context in the match?