📄 l5.1
字号:
#print More Alteration - Targets When we first looked at the 'dd' and 'cc' commands, we said that they werespecial cases of more general commands. In fact, 'd' and 'c' are the basisfor some of the most powerful commands in vi. We'll only talk about the 'd'command here, but it's all applicable to 'c' as well. The idea behind targets is to somehow combine the simple idea of deletingthings with the movement commands, yielding a whole set of new commands.For example, the 'w' command will move the cursor ahead one word. The'dw' command will delete everything from where we are up to the beginningof the next word. ')' moves forward a sentence; 'd)' deletes a sentence.You can use this for practically all movement commands, including all of the following: - return space ^ $ 0 H L M w b e W B E ( ) f F t T ; , / ? n N Type 'ready' and try out these commands. Take your time and experiment!!#user#create Targets The idea behind targets is to somehow combine the simple idea of deletingthings with the movement commands, yielding a whole set of new commands.For example, the 'w' command will move the cursor ahead one word. The'dw' command will delete everything from where we are up to the beginningof the next word. ')' moves forward a sentence; 'd)' deletes a sentence.You can use this for practically all movement commands, including all of the following: - return space ^ $ 0 H L M w b e W B E ( ) f F t T ; , / ? n N Now you may be able to see the usefulness of the 't' and 'T' commands.Recall that 'tx' moves the cursor to the character before the next 'x' on theline. Therefore, 'dtx' will delete everything up to, but not including,the next 'x' on the line. 'dfx', on the other hand, will delete everythingup to and including the 'x'. Both commands have their uses. Remember that all of these targets can also be used with the 'c' command.That is, 'c3w' will allow you to change the next three words. When you try this, note that vi doesn't actually erase the words and then put you intoinsert mode (That's a lot of redrawing that may not be necessary). It insteadplaces a dollar sign at the last character to be changed. When you hitEscape to get out of insert mode, the line will be fixed up. Try it! In the next three lessons, we'll see other commands which, like 'c' and 'd',can use targets.-------------------------------------------------------------------------------#cat /usr/lib/learn/vi/longtext >> Targetsvi Targets#next5.2 10
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -