Vim can open files and create buffers using a variety of commands:
| Command | Action | Pattern |
|---|---|---|
| :edit | edit a file | :edit [path/to/file] |
| :read | read file into the text | :read [path/to/file] |
| :new | create a new empty window | |
| :enew | edit a new, unnamed buffer |
Commands that take paths generally accept both relative and absolute paths.
The commands summarized above each perform similar tasks, but the :read command offers an extra bit of functionality that can be useful in some situations: in addition to accepting a path as an argument, :read can also insert the output of shell commands into the current buffer. For example, to insert the current time into Vim one might execute:
:read !date '%T'
which calls the external date command then inserts its output at the current cursor location.
No-Name Buffers
You might have noticed that when a file is loaded into a buffer, the buffer takes the name of the file. When a new buffer is created it has no name, and therefore is called a "no-name" buffer. No-name buffers are like other buffers, and their content can be saved to a file (at which point they take the name of the saved file and are therefore no longer "no-name" buffers, or they can be simply thrown away.