Vim Tips to Get Better Editing Experience
When you want to use vim as IDE or just improve yours basic skills.
| Command | Description |
|---|---|
| ddkP | move entire line up |
| ddp | move entire line down |
| ciw""P or ciw’Ctrl+r"' | quote/unquote words |
| :g!/^[^#]/d | delete all lines wih comments |
| :norm IsomeText | add text before selected lines |
| Ctrl-a | increment number |
| Ctrl+x | decrement number |
| cgn / . | change current word but repeatable with dot . |
| :sp filename | horizontal split |
| :vsp filename | vertical split |
| :tabs | list all tabs |
| :tab split | copy current window |
| :tabn /gt | go to next tab |
| :tabp /gT | go to previous tab |
| :set listchars=eol:¬,tab:>·,trail:~,extends:>,precedes:<,space:␣ | show ALL white space characters |
| :term | terminal mode |
| :sh | go to terminal, Ctrl+D to get back to VIM |
| :w !sudo tee % | open file as normal user, save as root |
| :set noexpandtab :retab! | convert all spaces to tabs |
| :set expandtab :set tabstop=4 :set shiftwidth=4 :retab | convert all tabs to spaces |
| Use S in Normal mode, in new line press ESC in normal mode, then S | writing the correct indent depth |
| :w !diff % - | show differenve between the buffer and the file |
| Ctrl-w - | decrease the height of the current split by one line |
| Ctrl-w + | increase the height of the current split by one line |