Vi
Basic keys of vi editor for the ones who hate vi :)¶
Escape from every command¶
Esc
Start to insert text at cursor¶
Esc then i
Go to end of line and write/append text¶
Esc then Shift+a
Selecting line¶
Esc then v move ← → Up Down arrows to select section
Copy selection¶
do not push Esc after selecting
y
Paste selection¶
do not push Esc after selecting
- paste after cursor
p
- paste after cursor P
Delete selection¶
do not push Esc after selecting
d
Copy 1 line¶
Esc from selecting then y+y ( yes push 2 time y)
Delete 1 line¶
Esc
go on specific line and
d+d ( yes push 2 time d)
Undo¶
Esc
u
Redo¶
Esc
Ctrl+r
Repeat last command¶
Esc
. ( yes exactly DOT)
Search forward¶
Esc
/+string_to_search
Search forward insensitive¶
Add a \c character at the end for case insensitive
Esc
/+string_to_search+\c
Search backword¶
Esc
?+string_to_search
Search backword insensitive¶
Add a \c character at the end for case insensitive
Esc
?+string_to_search+\c
Search and replace¶
Esc
:+%s/+old word+/+new word+/+g
Search and replace with confirmation¶
Esc
:+%s/+old word+/+new word+/+gc
Save file¶
Esc
:+w
Save file and exit¶
Esc
++"\:"+"w"+"q"
Exit without saving (when we mess the file :D )¶
Esc
"\:"+"q"+"!"
Bonus¶
Show line number¶
Esc
:set number
Hide line number¶
Esc
:set nonumber
Selection of columns/blocks instead of line¶
Esc Ctrl+v
Repeat search¶
n