How do I switch between multiple files/buffers in Vim?
To list all buffers use “:ls”, to list buffers without file attached to (also known as unlisted buffers, ex. scratch buffer and help-window) use “:ls!” There are several ways to switch between multiple files. You can use the “:buffer” command to switch between multiple files. You can also shorten command as “:b” and use only part of the filename. For example,
:buffer file1 :buffer file2 :b e2
You can also use <TAB> after “:b” for autocompletion. Try also “:b” followed by <CTRL-d> to see all available buffers. This works also for “:e”. You can also use the CTRL-^ key to switch between buffers. By specifying a count before pressing the key, you can edit the buffer with that number. Without the count, you can edit the alternate buffer by pressing CTRL-^ You can also use the “:e #” command to edit a particular buffer:
To close a buffer use “:bd” -command. To execute command for all files in buffer-list use “:bufdo”