The book "Unix in a Nutshell" discusses about accessing multiple files on pages 572-573. There seem to be very useful commands such as ":e", ":e #", ":e new_file", ":n files", ":args", ":prev" and ":n!". The commands confuse me:
":n Edit next file in the list of files."
":args Display list of files to be edited."
":prev Edit previous file in the list of files."
I cannot see no real list when I do ":args". There is only a small text at the corner. I would like to see all files that I accessed with ":e", ie a list of files in the buffer.
Where can I see the list when I do the command ":n files"? What are the commands ":prev" and ":n" supposed to do? I got the error message:
There is only one file to edit.
Ctrl-W w to switch between open windows, and Ctrl-W h (or j or k or l ) to navigate through open windows. Ctrl-W c to close the current window, and Ctrl-W o to close all windows except the current one. Starting vim with a -o or -O flag opens each file in its own split.
You can either split vim windows by opening multiple files using -o , -O , -o2 parameters. Or if you're already editing multiple files in one window, you can use :ba to split horizontally or :vert ba to split vertically.
By default, Vim starts with a single window, which is enough for editing a single file. But sometimes, you may have to work on multiple files. Vim makes it easier to work with multiple files at once with its window management system, allowing you to work on multiple files at the same time within a single Vim session.
To split the vim screen horizontally, or open a new workspace at the bottom of the active selection, press Ctrl + w , followed by the letter 's' . In the example below, the left section has been split into two workspaces. To navigate to the bottom section hit Ctrl + w , followed by the letter 'j' .
I've not read the book in mention, but I'll try to explain how vim handles files.
Vim has buffers. You open every file with:
:e name_of_the_file.txt
(loads file in a buffer, i.e. "opens file")
You can also:
:e *.txt
Useful options while doing this are
:set laststatus=2
(to always show the statusline)
:set wildmenu
(to ease opening files)
If you have standard vim with netrw plugin, you can:
:e .
(for one of vim's file managers, so to say)
To manage buffers:
:ls
will give you a list of currently opened buffers (files)
:bnext
, and :bprevious
(or :bn
and :bp
) enable you to cycle through buffers
:bd
closes the buffer/file (buffer done)
Other buffer types serve other purposes (yanking/pasting, temporary, vim's internal, ... etc.)
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