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?
Vim – How to Edit Multiple Files
command linefileslinuxvim
Best Answer
First of all, in vim you can enter : (colon) and then help
help
, ala:help
for a list of self help topics, including a short tutorial. Within the list of topics move your cursor over the topic of interest and then press ctrl] and that topic will be opened.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
:next
or:n
for short.:wnext
is short for write current changes and then move to next file.There's also an analogous
:previous
,:wprevious
and:Next
. (Note that:p
is shorthand for:print
. The shorthand for:previous
is:prev
or:N
.)To see where you are in the file list enter
:args
and the file currently being edited will appear in[]
(brackets).Example:
result: