Vim – Edit Multiple Files – Multiple Buffers

If you want to work with multiple files at the same time and if you are new to vim you might not know what buffers are about. They’re really useful. Here is a short blog on how to use them.

  • When you start vim you can start with multiple file arguments in the first place. Then all of them are opened together in different buffers.
  • When you want to open another file as another buffer you can say, :e filename/path
  • You can say :ls to list the active buffers. They are ordered and numbered.
  • You can use the list number of the buffer to switch to that buffer, by saying :b #. Replace # with the number.
  • You can also switch using the file name by saying,:b filename/path. Partially filling the name of the file and pressing tab also works.
  • To delete a buffer say :bd #. As previously mentioned, replace # with the list number. You can also use the filename/path.
  • Before you can switch from one buffer to another it needed to be saved by saying, :w. Not sure if this can be changed in some global settings.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s