58

I would like to open a file that already exists while already in Vim.

What is the command to do this?

Adam
  • 2,758
  • 2
    You should find yourself a nice cheat sheet such as this one https://www.reddit.com/r/vim/comments/32r85c/this_is_my_favorite_vim_cheat_sheet_does_anyone/ – Gerhard Burger Jun 21 '16 at 06:55

2 Answers2

82

vim [your file]

If this isn't working for you, make sure you have it installed with:

sudo apt-get install vim

If you're already IN vim do

:edit [your file]

Additionally, to move back to the previous file after you finish editing the new file you can use

:e#

This will return you to the previous file

Mitch
  • 4,827
29

You can also use tabs and split views:

:tabe /path/to/file

Effect: enter image description here

:vs /path/to/file

(or :sp for a horizontal split)
Effect: enter image description here

Use :tabn, :tabp to navigate between tabs, and CtrlW with the arrow keys to navigate between splits.

muru
  • 207,970