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

How do I jump back to where I was before my last search?

Answer

``

Explanation

The double backtick `` jumps to the exact position before the last jump. Since searches count as jumps, this takes you back to where you were before searching.

How it works

  • `` returns to the exact line and column before the last jump
  • Any command that creates a jump entry triggers this (search, G, %, etc.)
  • Pressing `` again toggles between the two positions

Example

You are on line 10, column 5. You search with /error which lands on line 80. Pressing `` returns to line 10, column 5.

Tips

  • '' returns to the line (first non-blank) instead of exact position
  • <C-o> goes further back in the jump list
  • `` only remembers the single previous position, while <C-o> has the full history
  • This is the quickest way to "undo" a navigation jump

Next

How do you yank a single word into a named register?