Usually 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”.