I know I can open multiple files with
vim by doing something like
vim 2011-12*.log, but how can I switch between files and close the files one at a time? Also, how can I tell the file name of the current file that I'm editing?
First of all, in vim you can enter : (colon) and then help
A good place for you to start would be the topic
Ok, on to your answer.
After starting vim with a list of files, you can move to the next file by entering
There's also an analogous
To see where you are in the file list enter
you can open another file while vim is open with
The keyboard shortcuts gT and gt can also be used to switch tabs when you are not in editing mode (i.e. not in insert, replace etc modes). On some systems Ctrl+Alt+Page Up and Ctrl+Alt+Page Down also allow tab-switching, but this does not always work (for example, it won't work in the OS X terminal 'out of the box').
And you can see the filename at the top of the vim app.
Commands to switch between buffers:
To know filename use Ctrl+G or
Another option apart from the answers given, is to split the window with:
I asked a similar question at superuser,
The answer to my question was you can't, but you can open two files in one bash window using VIM's
My bash is black and white, so the file name of each screen is styled as a reversed 'selected' line with the file name cited there.
Whenever I have to edit 3-4 text files in VIM, I used to run the command
It will open all four files in parallel. Focus will be on first file by default. To navigate to other files, I use the command
There are a lot of way to do so. The first one, maybe the less convenient, is to call
It calls the two files in two buffers. To switch from a file to another, please use
This should answer your question. But here are more information:
There is a way to edit your files in a more convenient way by splitting your console screen using vim. To do this, open two frames with
Now, if you'd like to see the differences between files, use the
Please let me know if you have some issue.
I find the most convenient method of editing multiple files is by using tabs. You can open multiple files in separate tabs via the command line like so:
Or if you already have vim open, you can open a new file in a new tab like so:
Once you have the tabs open, use
You can also jump to the first tab with
You can close tabs using
Finally you can move the current tab to the
I like to use split windows - both horizontal and vertical - to edit multiple files.
I use tmux to manage those windows more easily
https://tmux.github.io/ "What is a terminal multiplexer? It lets you switch easily between several programs in one terminal, detach them (they keep running in the background) and reattach them to a different terminal. And do a lot more. See the manual."