I have become fond of Vi/Vim in recent years. For most of my typing works I prefer to use Vim. Well editors which provide vim emulation. So I thought why not share the vim commands that I use most.
Lets start with the basics :).
Phew... the list got bigger than I expected. And these are only the ones I use in my regular vim activity. Furthermore, I consider myselft just a novice of vim :p.
Lets start with the basics :).
Moving arround:
| Command | Description |
|---|---|
| h | move the cursor left |
| j | move the cursor down |
| k | move the cursor up |
| l | move the cursor right |
Moving arround (advance):
And some advance command for moving arround..| Command | Description | Remarks |
|---|---|---|
| w | move cursor to the next word | W does the same but considers special characters part of word |
| b | Same as w, but works backwords | B is same as W, but works backwords |
| e | Same as w, but cursor moves to the end of word | Same as W, but cursor moves to the end of word |
| % | Go to the matching bracket | |
| ( | Goto start of sentence | |
| ) | Goto end of sentence | |
| ^ | Goto first printable character of the line | |
| 0 | Goto start of the line | |
| $ | Goto end of the line | |
| H | Move cursor to the first viewable line | |
| L | Move cursor to the last viewable line | |
| zz | Move window such that the cursor comes to the middle of the screen |
Manipulating Text:
| Command | Description | Remarks |
|---|---|---|
| u | Undo last action | |
| x | delete character under cursor | |
| dw | delete one word | can be used with other movement commands |
| dd | delete whole line | |
| I | Goto start of the first printable character on the line and switch to insert mode | |
| a | Switch to insert mode after the character under cursor | |
| A | Goto end of line and switch to insert mode | |
| o | insert line below current line and goto insert mode | |
| O | insert line above current line and goto insert mode | |
| y | Copy/yank character under cursor | yy copies current line |
| p | paste copied text | |
| ~ | change letter case | |
| v | turn on selection mode | you can use movement commands to selecte texts in visual mode |
Searching
| Command | Description | Remarks |
|---|---|---|
| / | searches the following text starting from the cursor and forward | type the text to be searched after the / and press enter |
| n | goto the next occurence of the searched text | |
| N | goto the previsou occurence of the searched text |
Miscelleneous:
| Command | Description |
|---|---|
| zo | Open folded lines |
| zc | fold the foldable region the cursor is currently in |
Ex Commands
Now some ex commands. (These commands are given using :) -| Command | Description |
|---|---|
| :w | save file |
| :q | quit vim |
| :%sort | sort all lines in the files lexicographically |
| :nohl | turn off highlighing of searched items |
| :syntax on | turn on syntax highlighting |
| :set ft=<filetype> | sets filetype of the file for syntax highlighting |
| :set wrap | turns on wrapping of lines |
| :set nowrap | turns off wrapping of lines |
Phew... the list got bigger than I expected. And these are only the ones I use in my regular vim activity. Furthermore, I consider myselft just a novice of vim :p.
No comments:
Post a Comment