VIM Study(3)--Modify text
To insert the characters you typed into the file, you need to change from command mode to insert mode. The two basic ways are i command and a command. which begin insertion right at the cursor or after the cursor. But there are several other commands (I A o O) which are very useful.
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 |
Replace or change text
Replacing means removing some text and beginning inserting new text. This is equivalent to deleting first and then entering insert mode. But the saving of a couple of keystrokes can make you feel really good.Change a single character -- r
This is a magic command that you must know. To change the character at the cursor position, just press r followed by the new character you want. The magic part is that you're still in command mode.Replace all stuff from cursor to the end of the line -- C
Get rid of all stuff from cursor to the end of line, and begin inserting new text.Replace by typing over -- R
Enter the replace mode. The character you're typing replaces the one at cursor position, and the cursor moves forward.Replace a word -- cw
Remove the word at the cursor, and beginning inserting new one.Labels: ASIC/IC Studybook
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home