2

I make use of the builtins in spf13. Today when I open multiple files with vim and want to close one of them with q it closes all these files, how can I close only a few of them without closing them all?

  • Can you be more specific? How do you open many different files? Are you using split windows or just separate buffers? When you say "q", do you mean typing :q and pressing "Enter"? If you can get a specific example of what you do, what you see happens and what you'd like to see instead, that would make it easier to answer your question... – filbranden Aug 31 at 18:18
  • Thank you for your comment. I open two files with vim -u NONE test14.sh test15.sh and I want to exit the editing of one file but still editing the other one, so I type :q. The result is I quit the vim and shell displays 2 files to edit. – Jingyu Gong Sep 1 at 6:51
1

This is not specific to spf13, but it applies to all Vim. If you've loaded multiple files in the given manner, vim will issue such warning message because q will try to quit Vim, but there are other files that haven't been edited yet.

Instead, after you're done editing with the current file, you can go to next file using :next. If you want to go back to previous file, you can do :Next, with capital N.

You can also use buffer commands, which is what I recommend. You can use :ls to list all buffers, :bnext, :bprev, to go go to next/previous buffers, and :buffer 5 to go to 5th buffer, etc.

To close and unload the current buffer, you can also do :bdelete (or :bd for short), and keep other buffers.

  • Thank you for your answer, this answer does solve my problem during manipulating multiple files. – Jingyu Gong Sep 5 at 14:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.