VimTutor
VimTutor-note | Vim on git | Vim-galore | Vim | SpaceVim | Hack SpaceVim
感觉vimtutor是众多vim帮助文档中最好的入门教程,其中的每一个知识点都有相应
的习题,可以让你在短时间内掌握基本的VIM操作。
想要入门vim的童鞋最好还是一边看文档,一边用vim自己尝试每个命令。
请通过vim练习:vim Vimtutor.txt
===============================================================================
W e l c o m e t o t h e V I M T u t o r - Version 1.7
欢迎使用VIM教程 1.7版
===============================================================================
Vim is a very powerful editor that has many commands, too many to
explain in a tutor such as this. This tutor is designed to describe
enough of the commands that you will be able to easily use Vim as
an all-purpose editor.
VIM是一个强大的编辑器,它拥有大量的命令,不可能在本教程中全部解释。但是,本
教程描述了足够多的命令,使你能轻松将VIM作为通用编辑器。
The approximate time required to complete the tutor is 25-30 minutes,
depending upon how much time is spent with experimentation.
完成本教程的时间大约是25-30分钟,主要依赖于你在实验中花去的时间。
ATTENTION:
The commands in the lessons will modify the text. Make a copy of this
file to practise on (if you started "vimtutor" this is already a copy).
注意:
本课程中的命令会改变本文的内容,请创建一个副本来练习(如果你用命令“vimtutor"
开始,本文已经是自动生成的副本了)。
注:创建副本的命令为:
vim -u NONE -c 'e $VIMRUNTIME/tutor/tutor' -c 'w! vimtutor_copy' -c 'q';ls -l
It is important to remember that this tutor is set up to teach by
use. That means that you need to execute the commands to learn them
properly. If you only read the text, you will forget the commands!
很重要的一点是,要记住,本教程是用于指导VIM的使用。这意味着你需要执行命令
以正确地学习它们。如果你只是单纯阅读本文,你会很快忘记这些命令!
Now, make sure that your Shift-Lock key is NOT depressed and press
the j key enough times to move the cursor so that Lesson 1.1
completely fills the screen.
现在,请确保你的shift键是启用的,多次按 j 键移动到1.1课,使之
居于屏幕中心。
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Lesson 1.1: MOVING THE CURSOR
1.1课:移动光标
To move the cursor, press the h,j,k,l keys as indicated.
要移动光标,则按示意按下 h,j,k,l 键
^
k Hint: The h key is at the left and moves left.
< h l > The l key is at the right and moves right.
j The j key looks like a down arrow.
v
示意:
-左边的h键是往左移
-右边的l键是往右移
-j键是往下移
-
Move the cursor around the screen until you are comfortable.
在屏幕中移动光标到你觉得合适的地方。 -
Hold down the down key (j) until it repeats.
Now you know how to move to the next lesson.
按住j键,使之重复作用。
现在你知道了怎么移动到下一节了吧。 -
Using the down key, move to Lesson 1.2.
使用下移键,移动到1.2节。
NOTE: If you are ever unsure about something you typed, press
you in Normal mode. Then retype the command you wanted.
注意:如意你不确定你按下了什么,按
NOTE: The cursor keys should also work. But using hjkl you will be able to
move around much faster, once you get used to it. Really!
注意:光标键同样生效。但hjkl键会使你移动得更快,只要你熟悉了它。真的!
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Lesson 1.2: EXITING VIM
1.2节:退出VIM
!! NOTE: Before executing any of the steps below, read this entire lesson!!
!! 注:执行以下步骤前,请读完全节!!
-
Press the
key (to make sure you are in Normal mode).
按下键(确保你处于正常模式)。 -
Type: :q!
.
This exits the editor, DISCARDING any changes you have made.
按: :q!.
此命令使编辑器退出并放弃你作的作用改动。(即不保存对文本的编辑) -
When you see the shell prompt, type the command that got you into this
tutor. That would be: vimtutor
当你看见shell提示时,输入以下命令并进入本教程:vimtutor
注:事实上你vimtutor是打开一个副本,你也可以打开你之前创建的副本:
vim vimtutor_copy -
If you have these steps memorized and are confident, execute steps
1 through 3 to exit and re-enter the editor.
如果你已经记住的这些步骤并有信心了,就执行步骤1-3退出,然后再进入编辑器。
NOTE: :q!
will learn how to save the changes to a file.
注:q!
- Move the cursor down to Lesson 1.3.
移动光标到1.3节。
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Lesson 1.3: TEXT EDITING - DELETION
1.3节:文本编辑之删除
Press x to delete the character under the cursor.
按下x键以删除光标所在的字符.
-
Move the cursor to the line below marked --->.
移动光标到--->标记的行。 -
To fix the errors, move the cursor until it is on top of the
character to be deleted.
为了修复错误,移动光标到要删除字符上。 -
Press the x key to delete the unwanted character.
按下x键以删除不想要的字符。 -
Repeat steps 2 through 4 until the sentence is correct.
重复步骤2到4,直到语句正确。
---> The ccow jumpedd ovverr thhe mooon.
- Now that the line is correct, go on to Lesson 1.4.
现在语句正确了吧,请移步1.4节。
NOTE: As you go through this tutor, do not try to memorize, learn by usage.
注:浏览本教程时,不要试着去记,而是学习其用法。
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Lesson 1.4: TEXT EDITING - INSERTION
1.4节:文本编辑之插入
Press i to insert text.
按下 i键 以插入文本
-
Move the cursor to the first line below marked --->.
移动光标到--->标记的行。 -
To make the first line the same as the second, move the cursor on top
of the first character AFTER where the text is to be inserted.
为使第一行同第二行相同,移动光标到要插入文本处字符上。 -
Press i and type in the necessary additions.
按下i键,键入需要的字符。 -
As each error is fixed press
to return to Normal mode.
Repeat steps 2 through 4 to correct the sentence.
当错误被修复后,按下回到正常模式。重复步骤2到4以修改完整。
---> There is text misng this .
---> There is some text missing from this line.
- When you are comfortable inserting text move to lesson 1.5.
当你正确插入完文本后,移步1.5节。
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Lesson 1.5: TEXT EDITING - APPENDING
1.5节:文本编辑之追加
Press A to append text.
按下A键以追加文本
-
Move the cursor to the first line below marked --->.
It does not matter on what character the cursor is in that line.
移动光标到--->标记的行。
该行同下一行在字符上不匹配。 -
Press A and type in the necessary additions.
按下A键,然后键入要添加的内容。 -
As the text has been appended press
to return to Normal mode.
当添加完文本后按下<esc>,返回到正常模式。 -
Move the cursor to the second line marked ---> and repeat
steps 2 and 3 to correct this sentence.
移动光标到第二个--->标记的行。
---> There is some text missing from th
There is some text missing from this line.
---> There is also some text miss
There is also some text missing here.
- When you are comfortable appending text move to lesson 1.6.
当你正确添加了文本后,请移步1.6节。
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Lesson 1.6: EDITING A FILE
1.6节:编辑一个文件
Use :wq to save a file and exit.
:wq 保存文件并退出
!! NOTE: Before executing any of the steps below, read this entire lesson!!
!! 注: 执行以下步骤之前,请读完全节!!
-
Exit this tutor as you did in lesson 1.2: :q!
Or, if you have access to another terminal, do the following there.
像1.2节一样,退出本教程: :q!
或者,你也可以访问其它的终端,并执行以下几步。 -
At the shell prompt type this command: vim tutor
'vim' is the command to start the Vim editor, 'tutor' is the name of the
file you wish to edit. Use a file that may be changed.
在shell提示符下,键入此命令: vim tutor
'vim' 是要启动的vim编辑器,‘tutor'是编辑的文件名。该文件将被编辑修改。 -
Insert and delete text as you learned in the previous lessons.
按照你在前几节你所学到的插入、删除文本。 -
Save the file with changes and exit Vim with: :wq
保存对文件的修改,并退出vim: :wq -
If you have quit vimtutor in step 1 restart the vimtutor and move down to
the following summary.
如果你在步骤1中退出了本教程,启动本教程并移步到以的总结。 -
After reading the above steps and understanding them: do it.
阅读完以下几步后,理解并执行它们。
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Lesson 1 SUMMARY
课程1 的 总结
-
The cursor is moved using either the arrow keys or the hjkl keys.
h (left) j (down) k (up) l (right)
可以使用光标键或者hjkl键移动光标
h (左移) j (下移) k (上移) l (右移) -
To start Vim from the shell prompt type: vim FILENAME
从sheel提示符启动VIM,请键入:vim FILENAME <ENTER> -
To exit Vim type: <ESC> :q! <ENTER> to trash all changes.
OR type: <ESC> :wq <ENTER> to save the changes.
要退出VIM: <ESC> :q! <ENTER> 放弃所有修改。
或者键入: <ESC> :wq <ENTER> 保存所有的修改。
-
To delete the character at the cursor type: x
删除光标处的一个字符: x -
To insert or append text type:
i type inserted text <ESC> insert before the cursor
A type appended text <ESC> append after the line
插入或者追加文本:
i type inserted text <ESC> 插入文本
A type appended text <ESC> 追加文本
NOTE: Pressing <ESC> will place you in Normal mode or will cancel
\ an unwanted and partially completed command.
注: 按下<ESC> 会回到正常模式,或者取消示完成的命令。
Now continue with Lesson 2.
现在继续进行第2课。
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Lesson 2.1: DELETION COMMANDS
2.1节:删除命令
Type dw to delete a word.
键入 dw 以删除一个单词.
-
Press <ESC> to make sure you are in Normal mode.
按下 <ESC> 以确保你牌正常模式。 -
Move the cursor to the line below marked --->.
移动光标到以下以--->标记的行。 -
Move the cursor to the beginning of a word that needs to be deleted.
移动光标到需要删除的单词头。 -
Type dw to make the word disappear.
键入 dw 以使该单词消失(被删除)。
NOTE: The letter d will appear on the last line of the screen as you type
it. Vim is waiting for you to type w . If you see another character
than d you typed something wrong; press <ESC> and start over.
注: 当你键入d时,字d 会在屏幕最低处显示,此时VIM在等待你键入w。 当你错误的键入时,你会看见其它的字符而非d;按下 <ESC> 重新开始。
---> There are a some words fun that don't belong paper in this sentence.
- Repeat steps 3 and 4 until the sentence is correct and go to Lesson 2.2.
重新步骤3到4,直到语句正确,然后移步2.2节。
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Lesson 2.2: MORE DELETION COMMANDS
2.2节:其它的删除命令
Type d$ to delete to the end of the line.
键入 d$ 以删除光标到行尾间处的字符
-
Press <ESC> to make sure you are in Normal mode.
按下 <ESC> 以确保你处于正常模式。 -
Move the cursor to the line below marked --->.
移动光标到以下以--->标记的行。 -
Move the cursor to the end of the correct line (AFTER the first . ).
移动光标到正确行的末端(在第一个.号后)。 -
Type d$ to delete to the end of the line.
键入 d$ 以删除到行尾。
---> Somebody typed the end of this line twice. end of this line twice.
- Move on to Lesson 2.3 to understand what is happening.
移动到2.3节,并理解发生了什么。
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Lesson 2.3: ON OPERATORS AND MOTIONS
2.3节:关于操作码和对象
(operator我理解为操作码,motions我理解为对象)
Many commands that change text are made from an operator and a motion.
The format for a delete command with the d delete operator is as follows:
d motion
Where:
d - is the delete operator.
motion - is what the operator will operate on (listed below).
A short list of motions:
w - until the start of the next word, EXCLUDING its first character.
e - to the end of the current word, INCLUDING the last character.
$ - to the end of the line, INCLUDING the last character.
Thus typing de will delete from the cursor to the end of the word.
NOTE: Pressing just the motion while in Normal mode without an operator will
move the cursor as specified.
许多修改文本的命令由两部分组成:操作码和对象。
删除命令d的格式如下:
d 对象
其中:
d -是操作码
motlion -是操作码要操作的对象(译者:更确切地说应是范围吧?)(罗列在下方)
关于对象的小清单:
w -到下一个单词头,除开所在的第一个字符。
e -到下一个单词尾,包括所在单词的最后一个字符。
$- 到行尾,包括了最后一个字符。
0- 到行首,包含空格。
^ -到行首,不含空格。
G -到文本最后一行首
gg -到文本首行。
所以de会删除光标处到单词尾下的字符。
注: 不带操作码按下对象键时,仅会按对象指定的方式 移动光标。
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Lesson 2.4: USING A COUNT FOR A MOTION
2.4节:对对象使用计数
Typing a number before a motion repeats it that many times.
-
Move the cursor to the start of the line marked ---> below.
-
Type 2w to move the cursor two words forward.
-
Type 3e to move the cursor to the end of the third word forward.
-
Type 0 (zero) to move to the start of the line.
-
Repeat steps 2 and 3 with different numbers.
---> This is just a line with words you can move around in.
- Move on to Lesson 2.5.
在对象前键入重复的次数.
-
移动光标到以下以--->标记的行。
-
键入 2w 以使光标向后移动两个单词。
-
键入 3e 以使光标向后移动到第三个单词尾。
-
键入 0 移动到行首。
-
使用不同 的数字重复步骤2到3.
---> This is just a line with words you can move around in.
- 移步到2.5节。
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Lesson 2.5: USING A COUNT TO DELETE MORE
2.5节:使用计数以删除得更多
Typing a number with an operator repeats it that many times.
为操作码键入 一个数字,使之重复多次.
In the combination of the delete operator and a motion mentioned above you
insert a count before the motion to delete more:
d number motion
合并上文提到的删除操作码和对象,在对象前插入一个数字以删除更多
d 数字 对象
-
Move the cursor to the first UPPER CASE word in the line marked --->.
移动光标到以下以--->标记的行的第一个大写单词处。 -
Type d2w to delete the two UPPER CASE words
键入 d2w 以删除2个大写 单词。 -
Repeat steps 1 and 2 with a different count to delete the consecutive
UPPER CASE words with one command
用不同的计数重复步骤1和2,以一个命令删除多个连续的大写单词。
---> this ABC DE line FGHI JK LMN OP of words is Q RS TUV cleaned up.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Lesson 2.6: OPERATING ON LINES
2.6节:行的操作
Type dd to delete a whole line.
键入 dd 以删除一整行.
Due to the frequency of whole line deletion, the designers of Vi decided
it would be easier to simply type two d's to delete a line.
由于需要频繁的删除一整行,vi的设计者决定通过简单的键入两d轻松删除一整行。
- Move the cursor to the second line in the phrase below.
- Type dd to delete the line.
- Now move to the fourth line.
- Type 2dd to delete two lines.
- 移动移动到以以下短语的第二行。
- 键入 dd 以删除行。
- 现在移动到第四行。
- 键入 2dd 以删除后两行。
---> 1) Roses are red,
---> 2) Mud is fun,
---> 3) Violets are blue,
---> 4) I have a car,
---> 5) Clocks tell time,
---> 6) Sugar is sweet
---> 7) And so are you.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Lesson 2.7: THE UNDO COMMAND
2.7节:恢复命令
Press u to undo the last commands, U to fix a whole line.
按下u 以恢复最后的命令,U 是修复一整行.
- Move the cursor to the line below marked ---> and place it on the
first error. - Type x to delete the first unwanted character.
- Now type u to undo the last command executed.
- This time fix all the errors on the line using the x command.
- Now type a capital U to return the line to its original state.
- Now type u a few times to undo the U and preceding commands.
- Now type CTRL-R (keeping CTRL key pressed while hitting R) a few times
to redo the commands (undo the undo's). - 移动光标到以--->标记的行,定位到第一处错误。
- 键入 x 以删除第一个不要的字符。
- 现在 键入 u 以恢复最后执行的命令。
- 这次用x命令修复该行的所有错误。
- 现在键入一个大写的 U 以回到行的原始状态。
6.现在按几次 u 以恢复U 和之间的命令。 - 现在 按几次 CTRL+R(按住CTRL同时敲击R),以撤消恢复命令(与u命令相反)。
---> Fiix the errors oon thhis line and reeplace them witth undo.
- These are very useful commands. Now move on to the Lesson 2 Summary.
- 这些都是非常有用的命令。现在移步到第2课的总结。
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Lesson 2 SUMMARY
第2课总结
-
To delete from the cursor up to the next word type: dw
删除光标到下一个单词: dw -
To delete from the cursor to the end of a line type: d\(<br /> 删除光标到行尾: d\)
-
To delete a whole line type: dd
删除整行: dd -
To repeat a motion prepend it with a number: 2w
预置数字以重复对象: 2w -
The format for a change command is:
operator [number] motion
where:
operator - is what to do, such as d for delete
[number] - is an optional count to repeat the motion
motion - moves over the text to operate on, such as w (word),
$ (to the end of line), etc
更改命令的格式:
操作码 [数字] 对象 -
To move to the start of the line use a zero: 0
用0移动到行首: 0 -
To undo previous actions, type: u (lowercase u)
To undo all the changes on a line, type: U (capital U)
To undo the undo's, type: CTRL-
恢复之前的动作,键入: u (小写)
恢复对一行的所有改变,键入:U(大写)
恢复恢复,键入: CTRL-R
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Lesson 3.1: THE PUT COMMAND
3.1节:PUT命令
Type p to put previously deleted text after the cursor.
输入 p 以在光标处粘贴先前删除的文本.
-
Move the cursor to the first ---> line below.
移动光标到以下以--->标记的行。 -
Type dd to delete the line and store it in a Vim register.
输入 dd 以删除该行,该行会被存储至VIM寄存器中。 -
Move the cursor to the c) line, ABOVE where the deleted line should go.
移动光标到c)行,即被删除行要到达的前行。 -
Type p to put the line below the cursor.
键入 p 将那行粘贴到光标之下。 -
Repeat steps 2 through 4 to put all the lines in correct order.
重复步骤2到4以粘贴所有的行到正确的位置。
---> d) Can you learn too?
---> b) Violets are blue,
---> c) Intelligence is learned,
---> a) Roses are red,
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Lesson 3.2: THE REPLACE COMMAND
3.2节:替换命令
Type rx to replace the character at the cursor with x .
键入 rx 以替换光标处的字符
-
Move the cursor to the first line below marked --->.
移动光标到以--->标记的行。 -
Move the cursor so that it is on top of the first error.
移动光标到第一个错误。 -
Type r and then the character which should be there.
键入 r和要更正的字符。 -
Repeat steps 2 and 3 until the first line is equal to the second one.
重复步骤2和3,直到一二行相同。
---> Whan this lime was tuoed in, someone presswd some wrojg keys!
---> When this line was typed in, someone pressed some wrong keys!
- Now move on to Lesson 3.3.
现在移动到3.3节吧。
NOTE: Remember that you should be learning by doing, not memorization.
注:记住你应该学会做而非记。
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Lesson 3.3: THE CHANGE OPERATOR
3.3:变更操作码
To change until the end of a word, type ce .
要变更光标到词尾,键入:ce
-
Move the cursor to the first line below marked --->.
移动光标到以--->标记的行。 -
Place the cursor on the u in lubw.
定位光标至 lubw 的 u 上。 -
Type ce and the correct word (in this case, type ine ).
键入 ce 和 正确的单词(本例中,应该键入 ceine). -
Press <ESC> and move to the next character that needs to be changed.
按<esc>,并移动到下一个需要更改的字符。 -
Repeat steps 3 and 4 until the first sentence is the same as the second.
重复步骤3和4,以使第一句同第二句相同。
---> This lubw has a few wptfd that mrrf changing usf the change operator.
---> This line has a few words that need changing using the change operator.
Notice that ce deletes the word and places you in Insert mode.
注意,ce 是删除单词并定位到插入模式(译者:其实后面的e就是对象,而前面的 c是操作码)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Lesson 3.4: MORE CHANGES USING c
3.4节:其它的c更改命令
The change operator is used with the same motions as delete.
同delete 命令一样,更改操作码也使用相同的对象。
-
The change operator works in the same way as delete. The format is:
c [number] motion
更改操作码的用法与删除操作码相同,格式为:
c [number] motion -
The motions are the same, such as w (word) and $ (end of line).
所有的对象是相同的,例如w(单词)、$(行尾)。 -
Move to the first line below marked --->.
移动到以下以--->标记的第一行。 -
Move the cursor to the first error.
移动光标到第一处错误。 -
Type c$ and type the rest of the line like the second and press <ESC>.
键入 c$ 和 余下的同第二行相同的字等符,并按下。
---> The end of this line needs some help to make it like the second.
---> The end of this line needs to be corrected using the c$ command.
NOTE: You can use the Backspace key to correct mistakes while typing.
注: 在键入时,你可以使用退格以删除错误。
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Lesson 3 SUMMARY
第3课总结
-
To put back text that has just been deleted, type p . This puts the
deleted text AFTER the cursor (if a line was deleted it will go on the
line below the cursor).
要粘贴刚刚删除的文本,键入 p.这会把被删文本粘贴到光标之后(如果某行被删,它会被粘贴到光标之后的一行)。 -
To replace the character under the cursor, type r and then the
character you want to have there.
要替换光标处的字符,键入 r 和要插入的字符。 -
The change operator allows you to change from the cursor to where the
motion takes you. eg. Type ce to change from the cursor to the end of
the word, c$ to change to the end of a line.
更改操作码允许你更改从光标到对象定义处。例如:键入 ce 以更改光标到词尾,键入c$会更改光标到行尾。 -
The format for change is:
c [number] motion
更改的格式:
c [number] motion
Now go on to the next lesson.
现在进入 下一课吧。
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Lesson 4.1: CURSOR LOCATION AND FILE STATUS
4.1节:光标定位和文件状态
Type CTRL-G to show your location in the file and the file status.
Type G to move to a line in the file.
键入 CTRL-G 以显示你在文件中的位置和状态.
键入G 以移动到文件行尾。
NOTE: Read this entire lesson before executing any of the steps!!
注:执行任何一步前请读完本课。
- Hold down the Ctrl key and press g . We call this CTRL-G.
A message will appear at the bottom of the page with the filename and the
position in the file. Remember the line number for Step 3.
按住CTRL键,并键入 g. 我们称之为CTRL-G。
在页面的底部会呈现一个信息,指出文件名和当前文件位置。
记住行号
以在第三步使用。
NOTE: You may see the cursor position in the lower right corner of the screen
This happens when the 'ruler' option is set (see :help 'ruler' )
注: 你可能见到 处于屏幕右下角的光标
这发生在设置了‘ruler'选项时(见 :hlep 'ruler')
-
Press G to move you to the bottom of the file.
Type gg to move you to the start of the file.
按 G 以移动到文件底。
键入 gg 以移动到文件首。 -
Type the number of the line you were on and then G . This will
return you to the line you were on when you first pressed CTRL-G.
键入你之前所在 的行号,然后键入G。
这样你会返回到你之前,即你按CTRL-G时的那一行。 -
If you feel confident to do this, execute steps 1 through 3.
如果你有信心去做它,请执行1到3步。
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Lesson 4.2: THE SEARCH COMMAND
4.2节:搜索命令
Type / followed by a phrase to search for the phrase.
按 / 并接一个要搜索的短语
-
In Normal mode type the / character. Notice that it and the cursor
appear at the bottom of the screen as with the : command.
在正常模式,键入 / 字母。注意,像:命令一样,光标会出现在屏幕底 -
Now type 'errroor'
. This is the word you want to search for.
现在,键入 'errroor'.这是你想要搜索的单词。 -
To search for the same phrase again, simply type n .
To search for the same phrase in the opposite direction, type N .
想再次搜索相同的短语,简单的键入 n.
想再次搜索相同的短语并以相反的方向,键入 N. -
To search for a phrase in the backward direction, use ? instead of / .
要反向搜索一个短语,使用?替换/. -
To go back to where you came from press CTRL-O (Keep Ctrl down while
pressing the letter o). Repeat to go back further. CTRL-I goes forward.
要返回之前的位置,键入 CTRL-O(按住 CTRL时,按下字母o).重复几次回到
更早的那刻。CTRL-I是向前移动。
---> "errroor" is not the way to spell error; errroor is an error.
NOTE: When the search reaches the end of the file it will continue at the
start, unless the 'wrapscan' option has been reset.
注: 当搜索到达文件尾时,它会从文件头开始搜索,除非’wrapscan'选项被设置了。
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Lesson 4.3: MATCHING PARENTHESES SEARCH
4.3节:括号匹配搜索
Type % to find a matching ),], or } .
键入 % 以找到所匹配的),],or }.
-
Place the cursor on any (, [, or { in the line below marked --->.
在以--->标记的行中,将光标定位到任一的(,[,{. -
Now type the % character.
现在按下 %字符。 -
The cursor will move to the matching parenthesis or bracket.
将光标移动到匹配的括号上。 -
Type % to move the cursor to the other matching bracket.
按 % 以移动光标到其它的匹配括号。 -
Move the cursor to another (,),[,],{ or } and see what % does.
移动光标到 另外的(,),[,],{ or },看看 % 是怎么做的。
---> This ( is a test line with ('s, ['s ] and {'s } in it. ))
NOTE: This is very useful in debugging a program with unmatched parentheses!
注:在高度程序的非匹配括号是这个是相当有用的。
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Lesson 4.4: THE SUBSTITUTE COMMAND
4.4:替换命令
Type
标签:VimTutor,---,键入,cursor,line,type,光标 From: https://www.cnblogs.com/lmc7/p/18115953