vim comes in two variants, a text-only version, and a GUI version, the latter is called gvim.
You can invoke the tutor by entering vimtutor at your shell.
删除一个单词的时候,光标要放在单词的首字母上。
The / command allows you to jump directly to some pattern in the file. For example, if you're looking for the next occurrence of the word "pomegranate" in your text, if you hit /, then type in pomegranate (you need not enter insert mode) and hit enter, the cursor will jump to the next occurrence of the word, if it exists. If you want to search backwards, you would perform the same procedure, but use the ? command. To repeat either search, enter //, ??, or alternatively, type / or ? and hit Enter. You can also press n to jump to the next occurrence, and N to jump to the previous occurrence.
Examples:
dw to delete a single word.
yw to yank a single word.
Example:
db to delete a single word before the cursor.
dW the capital W tells vi to go all the way to the first whitespace character after the word.
dB the capital B tells vi to go all the way to the first whitespace character before the word.
用m来给文档加标签,用`来定位到标签。例如:d`a来删除当前位置到标签间的内容。
Type ma. This will mark the current position that your cursor is at as mark a. You can go back to this position anytime you want from now on by typing `a. (`a means "move to the character that has been marked as a")
Now move to some other position. Type d`a. This will delete everything from the current position to the position you marked as a.
Some users find using mm to be a convenient temporary bookmark, because it can be typed so quickly.
d$ or d^
dG or d1G
d/myPattern
This is particularly useful when editing HTML files with d/<
In order to force vi to redraw the complete screen, press Ctrl-L
If you want to adjust what is currently displayed, then the
[/pattern/][m]z[n](
([ ... ] denotes optional items, (...|...) denotes alternatives)
Some common applications of the command,
Scroll the screen so the current line becomes the middle line of the screen. The cursor remains on that line:
z . 这个挺有用的,光标置中。
Scroll the screen so the current line becomes the top line on the screen:
z CR
Scroll the screen, so the current line becomes the bottom line of the screen:
z -
If a /pattern/ or a number m is given the cursor is moved further after the adjustment. /pattern/ indicates to move the cursor to the first match of that pattern. m indicates to move the cursor to the mth line on the screen. So, for example,
/while/z CR
would first scroll the screen so the current line becomes the top line on the screen, and then move the cursor to the first 'while' in the text from that position on.
The number n is a rather obscure parameter. If provided, it tells vi to behave as if the screen is just n lines high. The result is that only n number of lines are adjusted, and the rest of the screen is either ignored or cleared, presumably useful on slow terminals to avoid redrawing the screen unneccessarily
从这一章往下,我只跳着看了一点,有很多特别细节的功能,暂时用不上的都没有看。以后用熟练了之后再回来深入学习吧。