Tutorial for vim
Install vim
sudo apt install vim
git clone --depth=1 https://github.com/amix/vimrc.git ~/.vim_runtime
sh ~/.vim_runtime/install_awesome_vimrc.sh
Command mode
Start with ":"
- Create file
:e filename
- Save file and quit vim
:w # save the current file
:wq # save and quit
:q! # Discard the change and quit
:w filename # save as
common command
- Navigating A File
h j k l # Move the cursor left, down, up, or right.
# [←,↓,↑,→] in 87keys keyboard
# "Backspace"
[number][←,↓,↑,→]
w # Move to the next word
e # Move to the end of the current word
b # Move to the previous word
# Move to the begin of the current word
0 # Move to the beginning of the line.
# "Home" while using 87keys keyboard.
) # Move to the beginning of the next line.
# Shift+0
$ # Move to the end of the line.
# "End" while using 87keys keyboard.
Ctrl+f # "PgUp"
Ctrl+b # "PgDn"
gg # Go to first line
G # Go to last line
:[number] # Go to the special line
- Edit
yy
dd
p
x # "Del"
- Search characters or word
/[word]
n # Move to the next match
N # Move to the previous match
:noh # Turn the matching highlight
Visual mode
Most the commnad used in Command mode can also be used in Visual mode too. And most useful feature in the Visual mode is select code block and then edit text in bulk.
Insert mode
- Enter Insert mode from Command mode
i
I
a
A
s