Why Vim
Just because your workflow will be interrupted frequently when navigating your cursor is needed. But you can navigate easily with Vim compared with other text editor. Though it will take some time to get used to Vim, but in the long run, it’s definitely worth it.
Here is quick reference of the most commonly used vim command, hope it will help. So let’s get started!
Modes
Mode matters!
command mode
Where you start with and you will always here when not editing
insert mode
- insert,
i
orI
to insert at current position or beginning - append,
a
orA
to append after current position or end - open,
o
orO
to open a new line below or above
last line mode
Enter command :
in command mode(normal mode) to enter, and you will be able to perform amazing tasks.
:q
, quit:q!
, force quit, changes will not be save:wq
, write and quit:!ls
, you can issue linux or unix commands here:set number
, you can issue configuration for this session
Deletion
dw
, delete word from cursor ondb
, delete word backwarddd
, delete line(couldn’t be more convenient)d$
orD
, delete to end of lined^
, delete to beginning of linex
, delete character
Copy
Basic the same with deletion but begin with y
not d
.
yw
, copy word from cursor onyb
, copy word backwordyy
, copy current line(yy
andp
combo is very convenient)y$
, copy to end of current liney^
, copy to beggining of current linev
, start to copy text blockV
, linewise copy
Paste
Used after delete or yank to recover lines
p
, paste below cursorP
, paste above cursoru
, undo last changeU
, restore line
Change
Use to change word
cw
, change current word to a new word from cursorciw
, change inner word
Search
:/
, search forward:?
, search backwordn
, next
Navigation
hjkl
to navigate aroundgg
to file beginningG
to file end0
or^
to beginning of line$
to end of line
Resize windows
resize 60
res +5
vertical res +5
vertical resize 80
Mappings
Useful for some cases, I fall in love with vim mode when I know
- add
inoremap jj <Esc>
to file ~/.vimrc - also you can enable Esc by adding
inoremap <Esc> <Nop>