Working with multiple files "the vim way" is kind of tricky. I took me a long time finding how people did it... and then some more to get used to it.
Apparently the secret is the set hidden option and the buffer list. The :ls command will show you the list of open files. And you can navigate to any of those files with the :buffer command.
The cool thing about the :buffer command is that it can autocomplete using the paths of the opened files. So if you write something like :buffer main.js and then press Tab, vim will show you the completion list with the files that contain main.js. Accept the completion, press Enter and you're there.
The other piece of the puzzle will be the "alternate file", which is basically the most recently used file. If you use :buffer # you'll get there. Vim has a built-in shortcut for this: <C-^>, that is Ctrl + ^, which in QWERTY layouts is Ctrl + 6.
Additionally you could "chain" ls and buffer inside a keymap.
nnoremap <Leader>bb :ls<CR>:buffer<Space>
If this is still not enough for your workflow you can check out fzf and the companion plugin fzf.vim. (I'm almost certain you knew about this one).
Working with multiple files "the vim way" is kind of tricky. I took me a long time finding how people did it... and then some more to get used to it.
Apparently the secret is the
set hidden
option and the buffer list. The:ls
command will show you the list of open files. And you can navigate to any of those files with the:buffer
command.The cool thing about the
:buffer
command is that it can autocomplete using the paths of the opened files. So if you write something like:buffer main.js
and then press Tab, vim will show you the completion list with the files that containmain.js
. Accept the completion, press Enter and you're there.The other piece of the puzzle will be the "alternate file", which is basically the most recently used file. If you use
:buffer #
you'll get there. Vim has a built-in shortcut for this:<C-^>
, that isCtrl + ^
, which in QWERTY layouts isCtrl + 6
.Additionally you could "chain"
ls
andbuffer
inside a keymap.If this is still not enough for your workflow you can check out fzf and the companion plugin fzf.vim. (I'm almost certain you knew about this one).
Thanks for the tips!