Insert right here -- i
i means "insert". It switches your mode to insert mode and begin insertion at the current position of the cursor.Insert after the cursor -- a
a means "append". It moves the cursor forward by one character and switches your mode to insert mode. Therefore insertion begins after the position of the cursor when you pressed the a command.Insert at the beginning of the current line -- I
This is equivalent to ^iInsert at the end of the current line -- A
This is equivalent to $aInsert a new line below the current line -- o
If you haven't learned this command, perhaps you often move the cursor to the end of the line, enter insert mode and press Enter. Well, that's what o command does -- AEnterInsert a new line above the current line -- O
Delete text
To do deleting, keep yourself in command mode.Delete the character at the cursor position -- x
This is the most often used deletion command. To delete a character, use cursor motion commands to move the cursor to that character and press x.Delete the character at the left of the cursor -- X
I don't use this one since I think typing hx is easier than making an upper case X.Delete all the stuff from cursor to end of line -- D
This one can be very handy. But if you want to change the stuff from the cursor position to the end of line, using C might be even better, which is equivalent to DA.Delete the whole current line -- dd
You must learn this command. It makes you feel power. If you have several lines of text to delete, you can keep hitting dd and watch the lines disappearing. If you overdid it and removed some useful stuff, don't panic -- keep pressing u the removed lines will reappear in reverse order. u means "undo". vim has multiple levels of undo.Combine a move and the delete command -- dmove
Pressing d followed by a cursor motion command will delete all the text from the current cursor position to the position the move command pointed. This will make lots of magical commandsdw | delete from cursor to end of the word | |
dW | delete 1 word, including punctuation characters, if any. | |
d10w | delete 10 words (=10dw | |
d0 | delete from cursor to start of line | |
d$ | =D | |
dG | delete from current line to end of editing buffer | |
d1G | delete from current line to beginning of editing buffer |
No comments:
Post a Comment