This isn’t an extensive list.
I’m not a heavy vi user, so I often forget basic commands I want to use. So, this is a list of those commands.
Split screen
- vertically
CTRL + w and v
- horizontally
CTRL + w and s
Move between screens
- down
CTRL + w and j
- up
CTRL + w and k
- right
CTRL + w and l
- left
CTRL + w and h
Move cursor to …
- specific line
<line number> + gg
- top of the file
gg
- bottom of the file
G
- end of the line
$
Scroll page
- up
CTRL + b
- down
CTRL + f
Copy and paste multiple lines
- Press V (to enter VISUAL LINE mode)
- Select the lines you want to copy
- Press y (or d for cut instead of copy)
- Move the cursor to where you want to paste the lines
- Press p to paste
Comment out multiple lines
- Press CTRL + v (to enter VISUAL BLOCK mode)
- Move the cursor to select the lines you want to comment out
- Press I (to enter INSERT mode)
- Type # (in case of shell script)
- Enter ESC
Save file as …
:w <file name>
Open file
:e <file name>
Search selected word
- Search forward
*
- Search backward
#
Show/hide line number
- Show
:set number
- Hide
:set nonumber