How to effectively add a file to the args list for vim from within vim

vim

Really I just have a confusion between a few terms, some of which may be synonymous:

  • buffers
  • tabs
  • files
  • windows

I want to understand these terms fully and any pointers in that direction would be appreciated. However, my immediate question is:

I like the method of switching between files that I get when multiple files are listed as arguments for the vim command. However, sometimes I am in an editing session and I realize that I want to edit another file as well, using the same macros, registers, etc., and without ending the editing session. How can I open another file from within vim such that :n and :prev will allow me to switch to and from the new file?

Best Answer

Assuming you meant :prev (:p is short for :print, not :previous), you can add a file to the list by editing it:

:e filename

Or, if you don't want to switch to the new file immediately, you can add it to the list of arguments:

:argadd filename

The list of buffers is separate, while editing a new file does create a buffer, you can create a buffer without adding to the argument list:

:badd filename

To traverse the buffers, you can do :bn and :bp.

Related Question