Search code examples
vimsplitctags

Jumping back to a previously opened file in Vim


While using Vim I'll sometimes want to look at a function definition or a struct definition, so I'll use C-] to jump to it. However, there are a few problems I run into. First off, I don't know how to jump back easily. It appears the previous file I was in closes and I'm now in the new one. Is there a way to jump back, or keep a stack of open files that I can pop back to or something?

Another thing I've noticed that when I have a change in the current file I need to save it because, like a mentioned a moment ago, my current file is being closed before the next one opens.

And sometimes I want to view my current code and my header at once. Is there a way open the tag definition in a split?


Solution

  • Add

    set hidden
    

    to you vimrc. It'll allow you switch files without saving them. I think this is one of 'must have' options.

    Use C-o to jump back to previous locations which were autosaved in a jumplist.

    :h jumplist