Search code examples
vimvi

How do you open a file from within Vim?


I know how to open a file in Vim from a terminal (vim fileName). What I can't figure out is how to open a file when I'm already within Vim.

I tried :r fileName, but that appears to read (or append) the file into the unsaved buffer I have open. It creates a new file, because when I try to write it with :w, it asks for a filename.


Solution

  • :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.