There are many commands in VIM. Those I always use are listed below.
Insert Mode
- i - insert before the cursor
- I - insert at the beginning of line
- a - append after the cursor
- A - append at the end of line
- o - open a new line below
- O - open a new line above
- ESC - exit insert mode
Delete, Cut & Paste
- x - delete character
- dw - delete word
- dd - delete line
- yy - copy a line
- 2yy - copy 2 lines
- yw - copy a word
- y$ - copy to end of line
- p - paste after cursor
- P - paste before cursor
- r - replace 1 character
- :u = undo
Search & Replace
- /pattern - forward search
- ?pattern - backword search
- %s/old/new/g - replace old to new globally
Exiting :
- :w - write without exit
- :wq - write and exit
- :q - exit if no change
- :q! - exit and discard changes
My VIM Config ~/.vimrc
syntax on
|
Remarks
- # if CentOS, sudo yum install vim-enhanced
- for root user, vi ~/.bashrc
- alias vi='vim'
Reference