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

How do I return to my previous position after jumping to a tag?

Answer

<C-t>

Explanation

The <C-t> command pops the tag stack and returns to the position from which you last used <C-]> or :tag. It is the counterpart to tag jumping.

How it works

  • <C-t> pops one entry from the tag stack
  • Returns to the exact file, line, and column before the tag jump
  • Can be repeated to go back multiple tag jumps

Example

You jump from main.c:10 to utils.c:42 with <C-]>, then from utils.c:42 to helper.c:5. Pressing <C-t> returns to utils.c:42. Pressing <C-t> again returns to main.c:10.

Tips

  • :tags shows the tag stack
  • {count}<C-t> pops multiple entries at once
  • The tag stack is separate from the jump list
  • :pop is the Ex command equivalent

Next

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