In vim, how do I go back to where I was before a search?

Edward Tanguay picture Edward Tanguay · Sep 10, 2008 · Viewed 69.1k times · Source

Programming in vim I often go search for something, yank it, then go back to where I was, insert it, modify it.

The problem is that after I search and find, I need to MANUALLY find my way back to where I was.

Is there an automatic way to go back to where I was when I initiated my last search?

Answer

Agnel Kurian picture Agnel Kurian · Sep 10, 2008

Ctrl+O takes me to the previous location. Don't know about location before the search.

Edit: Also, `. will take you to the last change you made.