如何从 Vim 内部打开文件?

我知道如何从终端(vim fileName)在 Vim 中打开文件。我不知道的是如何打开一个文件,当我已经在 Vim。

我尝试了 :r fileName,但它似乎将文件读入(或追加)到我打开的未保存的缓冲区中。它创建一个新文件,因为当我尝试用 :w编写它时,它要求一个文件名。

98563 次浏览

:e <filename>

or

:Ex <directory>

lets you browse for the file from the given directory.

:Ex on its own will open the pwd.

:enew

will create an empty buffer.

Also, to open multiple files (or just one, so I tend to use this for opening a single file, since :e fails to open multiple files)

:n file1 file2

:n resets the argument list so it is as if you had entered them on the command line (so commands like :rew will work with this list), but :e does not.

this vim command you won't forget:

:Sex

if you want to point to certain dir, then :Sex <dir>