Short Tip: Write buffers and jump to next in Vim

920839987_135ba34fffUsually I wrote and close file in vim with “:wq”, write and quit vim. However, when I edit a bunch of files at the same time, like with “vim *txt”, I do not want to close vim but just one file and jump to the next. And most often I have forgotten how to do that, so this post is kind of a self reminder.

For handling multiple files you need to know that vim refers to files loaded into memory for editing is called “buffer”, and that these buffers are tracked in a list. So, whenever you edit a bunch of files and finished a file, you need to close the buffer, and delete it from the buffer list:


If you want to write the buffer and jump to the next file, there are two ways to approach this: either by deleting the buffer from the buffer list, or by just jumping to the next file without deleting it


Both commands write the current buffer and jump to the next file. The first one closes the buffer, however.

You can always check the buffer list with “:ls” – and jump forth and back between the buffers with “:n” and “:N”.


9 thoughts on “Short Tip: Write buffers and jump to next in Vim”

  1. You might also want to consider installing minibufexpl (, which is brilliant if you need to do work in several buffers. Personally, I switch it off when I’m coding, and use bufexplorer (, which makes for a much less cluttered workflow when you’re working with a lot of files. Also, NERDtree ( is pretty indispensable if you’re working on a whole tree of files (e.g. a coding project).

    1. Hej, looks interesting when you work with buffers more open. Right now I am just at the beginning of using buffers in Vim 😉

  2. Why delete buffers? They don’t seem to take up much space.

    My main use of buffers is :b AnyLetters , where AnyLetters is some minimal piece of the filepath of anything you’ve edited (e.g. st.h for StupidlyLongPath/MainFileName_test.html). vim will complete the path, pressing again will offer next match. Once it’s showing the file you want, press

    You can also enter :buffers to see a list and enter :b 3 load a particular numbered buffer.

    1. No comment preview, your comment box swallowed all my [Tab]s and [Enters] in angle brackets without warning, your WordPress login displayed an endless login bar without reporting failure, it’s asking for my password but doesn’t use https, it failed.

      Sigh. Probably not your fault, but why is WordPress so awful?

      Anyway, “type :b AnyLetters[Tab] for autocomplete of any matching file in your session, press [Tab] to advance to the next, then press [Enter].”

    2. Deleting buffers makes sense when the number of documents your are working with changes quite often over time. But thanks for the other tips as well =)

    3. @skierpage: Nothing here states that I allow bracket formatting. Why did you even try? That, btw., has *nothing* to do with WordPress, but all with configuration. Also, if https is not enforced during login, its a server problem. Again, not a WordPress problem. Btw., https login works perfectly for me here.
      Yes, there are many problems with WordPress – but none of them you mentioned are among them.

      But thanks for the tip with the autocompletion. =)

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 )

Google+ photo

You are commenting using your Google+ 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 )


Connecting to %s