The more I use VIM, the more it surprises me.
Here, I list some useful commands in everyday text editing. I have known some of them for long time. But others were learnt recently.
Command | Explanation | Note |
Delete | ||
cc | delete current lines and change to insert mode | |
dd | delete current lines | |
c{motion} | delete until the character {motion} moves to and change to insert mode. | |
d{motion} | delete until the character {motion} moves to | |
C | delete characters until the end of the line. Then change to insert mode | |
D | delete characters until the end of the line. | |
s | delete [count] characters and change to insert mode | |
x | delete [count] characters under and after the cursor | |
:[range]d | delete those lines in the range | |
S | delete [count] lines and change to insert mode | |
Replace | ||
R | Enter Replace mode | |
gR | ||
Line joining | ||
[range]J | join [count] lines | Steps of execution of these commands |
{Visual}J | join the selected lines | |
:[range]j[!] | join range lines. With !, the join doesn't insert/remove any spaces. | |
[range]gJ | join [count] lines | Don't insert or delete any spaces. |
{VIsual}gJ | join the selected lines |
Some commands useful in source code editing
Commands | Explanation |
<{motion} | shift covered lines leftwards by 1 shiftwidth |
>{motion} | shift covered lines rightwards by 1 shiftwidth |
{Visual}[count]< | shift selected lines leftwards by 1 shiftwidth |
{Visual}[count]> | shift selected lines rightwards by 1 shiftwidth |
[range]< | shift selected lines leftwards by 1 shiftwidth |
[range]> | shift selected lines rightwards by 1 shiftwidth |
<< | shit current line leftwards by 1 shiftwidth |
>> | shit current line rightwards by 1 shiftwidth |
No comments:
Post a Comment