Vim Cheatsheet
A simple cheatsheet I made when I was first using Vim/Neovim that I still use to this day.
Last updated: May 4th, 2023
Vital Commands
Opening Files
The most basic way to open a file in vim is to just call it as an argument:
$ vim path/to/file.txt
#You can open more than one file like this.
vim path/to/file1.txt path/to/file2.txt path/to/file3.txt
#Vim even supports connecting over urls
vim https://path/to/file1.txt ftp://path/to/file2.txt scp://path/to/file3.txt
Alternatively, if you open vim without arguments you can use :edit or :e to open files in write mode.
:e path/to/file4.txt
Basic Navigation
- k - up
- j - down
- l - right
- h - left
- Ctrl+f - bottom
- Ctrl+b - top
- :n - move to nth line
Basic Editing
To edit the document you need to enter
insert mode. You can do this by pressing
the i
key. To exit insert mode
you press the Esc
key
Closing the File
If you're in normal mode you can exit in two ways:
:wq #write changes to disk and quit.
:qa! # quit all open docs and ignore warnings.
Operators and Motions
Operators are commands and motions are what you want the command to act on.
List of Operators
- d - delete (adds to buffer, can paste)
- u - undo
- y - yank/copy
- p - put/paste
- r - replace
- c - change
- A - append
- / - search
- % - finds matching brackets
- :% - all occurences
- :r - pushes external data to cursor, can be file or external command
- :! - run external command
- :s/old/new/g
List of Motions
- w - until next word
- e - end of current word
- $ - end of line
List of Counts
- 0 - start of the current line
- n - n * motion