I need to jump back and forth between two files in Vim.
I can do this manually as :e file1.txt
followed by :e file2.txt
. Is there a shortcut to directly jump to the previously opened file?
Note: I don't want to open the two files in split windows or multiple tabs.
I'm looking for something like [ctrl + o]
, only the jump should be to previous file, not previous location in the same file
thanks for any hints
Use <C-^>
or <C-6>
.
From :h ctrl-^
:
Edit the alternate file. Mostly the alternate file is
the previously edited file. This is a quick way to
toggle between two files. It is equivalent to ":e #",
except that it also works when there is no file name.
If the 'autowrite' or 'autowriteall' option is on and
the buffer was changed, write it.
Mostly the ^ character is positioned on the 6 key,
pressing CTRL and 6 then gets you what we call CTRL-^.
But on some non-US keyboards CTRL-^ is produced in
another way.
I am not sure I understand correctly, but with only two files opened maybe buffer next
:bn
will be enough?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With