Useful Vim commands. #vim
Vim commands
# @Folding
| Command | Description |
|=======================:+=======================================|
| zM/zR | fold / unfold buffer |
| zc/zo | fold / unfold paragraph |
| zC/zO | fold / unfold all levels in paragraph |
| :set foldmethod=indent | fold by indendation |
| :set foldmethod=syntax | fold by syntax |
|------------------------+---------------------------------------|
# @Window control
| Command | Description |
|========:+==============================|
| n C-<> | dec / inc window width by n |
| n C-+- | inc / dec window height by n |
| C-w= | make windows equal size |
|---------+------------------------------|
# @External commands
| Command | Description |
|===============:+=====================================|
| :%!command | @filter buffer through command |
| :w !sudo tee % | @save file even if write protected |
|----------------+-------------------------------------|
# Manipulating @text
| Command | Description |
|========:+======================|
| yiw | yank word |
| yiwp | replace word |
| viw”0p | replace another word |
|---------+----------------------|
# @Marks
| Command | Description |
|========:+==============================|
| ma | set mark a |
| ‘a | jump to line with mark a |
| `a | jump to position with mark a |
|---------+------------------------------|
# @Jumping
| Command | Description |
|========:+========================|
| % | go to matching bracket |
| # | search backwards |
| C-o | go back after jump |
|---------+------------------------|
# @Pattern matching
| Command | Description |
|=============:+======================================|
| :g/pattern/d | @delete lines containing pattern |
| :v/pattern/d | @delete lines not containing pattern |
|--------------+--------------------------------------|
* * *