Command | Description |
---|---|
vim filename | Open file from terminal |
:e filename | Open file from within Vim |
:e | Reload current file |
:e! | Reload current file, discarding changes |
:enew | Open a new empty buffer |
:find filename | Find and open file in 'path' |
Command | Description |
---|---|
:w | Save current file |
:w filename | Save as a new file |
:w !sudo tee % | Save file with sudo privileges |
:wa | Save all open files |
:wq or ZZ | Save and quit |
:x | Save if modified and quit |
Command | Description |
---|---|
:q | Quit (fails if unsaved changes) |
:q! or ZQ | Quit without saving (discard changes) |
:qa | Quit all buffers/windows |
:qa! | Quit all buffers/windows without saving |
Command | Description |
---|---|
:bn | Go to next buffer |
:bp | Go to previous buffer |
:ls | List all open buffers |
:b number | Go to buffer by number |
:b filename | Go to buffer by filename (tab completion works) |
:bd or :bw | Close current buffer (delete or wipe) |
:sp filename | Open file in new horizontal split |
:vsp filename | Open file in new vertical split |
Ctrl-w s | Split window horizontally |
Ctrl-w v | Split window vertically |
Ctrl-w w | Switch between windows |
Command | Description |
---|---|
:Explore or :Ex | Open file explorer in current window |
:Sexplore or :Sex | Open file explorer in horizontal split |
:Vexplore or :Vex | Open file explorer in vertical split |
In the file explorer: use Enter to open a file/directory, - to go up a directory, d to create a directory, % to create a file.
Command | Description |
---|---|
:cd path | Change current directory |
:pwd | Print working directory |
:f or Ctrl-g | Display filename and position |
gf | Go to file under cursor |
:r filename | Insert contents of file |
:r !command | Insert output of shell command |