1. 程式人生 > >30分鐘學會vim之vimtutor(雙語版)

30分鐘學會vim之vimtutor(雙語版)

===============================================================================
= 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鍵是往下移
1. Move the cursor around the screen until you are comfortable.
1. 在螢幕中移動游標到你覺得合適的地方。

2. Hold down the down key (j) until it repeats.
Now you know how to move to the next lesson.
2. 按住j鍵,使之重複作用。
現在你知道了怎麼移動到下一節了吧。

3. Using the down key, move to Lesson 1.2.
3. 使用下移鍵,移動到1.2節。

NOTE: If you are ever unsure about something you typed, press <ESC> to place
you in Normal mode. Then retype the command you wanted.
注意:如意你不確定你按下了什麼,按<ESC>回到正常模式。再按你想要輸入的命令。

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!!
!! 注:執行以下步驟前,請讀完全節!!

1. Press the <ESC> key (to make sure you are in Normal mode).
1. 按下<ESC>鍵(確保你處於正常模式)。

2. Type: :q! <ENTER>.
This exits the editor, DISCARDING any changes you have made.
2. 按: :q! <ENTER>.
此命令使編輯器退出並放棄你作的作用改動。(即不儲存對文字的編輯)

3. When you see the shell prompt, type the command that got you into this
tutor. That would be: vimtutor <ENTER>
3. 當你看見shell提示時,輸入以下命令並進入本教程:vimtutor<ENTER>
譯者注:事實上你vimtutor是開啟一個副本,你也可以開啟你之前建立的副本:
vim vimtutor_copy

4. If you have these steps memorized and are confident, execute steps
1 through 3 to exit and re-enter the editor.
4. 如果你已經記住的這些步驟並有信心了,就執行步驟1-3退出,然後再進入編輯器。

NOTE: :q! <ENTER> discards any changes you made. In a few lessons you
will learn how to save the changes to a file.
注:q!<enter> 會取消你對文字所作的任何改動。在新的一節你會學到儲存檔案的修改。

5. Move the cursor down to Lesson 1.3.
5. 移動游標到1.3節。


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Lesson 1.3: TEXT EDITING - DELETION
1.3節:文字編輯之刪除


** Press x to delete the character under the cursor. **
**按下x鍵以刪除游標所在的字元.**

1. Move the cursor to the line below marked --->.
1. 移動游標到--->標記的行。

2. To fix the errors, move the cursor until it is on top of the
character to be deleted.
2. 為了修復錯誤,移動游標到要刪除字元上。

3. Press the x key to delete the unwanted character.
3. 按下x鍵以刪除不想要的字元。

4. Repeat steps 2 through 4 until the sentence is correct.
4. 重複步驟2到4,直到語句正確。

---> The ccow jumpedd ovverr thhe mooon.

5. Now that the line is correct, go on to Lesson 1.4.
5. 現在語句正確了吧,請移步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鍵 以插入文字**

1. Move the cursor to the first line below marked --->.
1. 移動游標到--->標記的行。

2. 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.
2. 為使第一行同第二行相同,移動游標到要插入文字處字元上。

3. Press i and type in the necessary additions.
3。按下i鍵,鍵入需要的字元。

4. As each error is fixed press <ESC> to return to Normal mode.
Repeat steps 2 through 4 to correct the sentence.
4. 當錯誤被修復後,按下<esc>回到正常模式。重複步驟2到4以修改完整。

---> There is text misng this .
---> There is some text missing from this line.

5. When you are comfortable inserting text move to lesson 1.5.
5. 當你正確插入完文字後,移步1.5節。



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Lesson 1.5: TEXT EDITING - APPENDING
1.5節:文字編輯之追加


** Press A to append text. **
**按下A鍵以追加文字**

1. Move the cursor to the first line below marked --->.
It does not matter on what character the cursor is in that line.
1. 移動游標到--->標記的行。
該行同下一行在字元上不匹配。

2. Press A and type in the necessary additions.
2. 按下A鍵,然後鍵入要新增的內容。

3. As the text has been appended press <ESC> to return to Normal mode.
3. 當新增完文字後按下<esc>,返回到正常模式。

4. Move the cursor to the second line marked ---> and repeat 
steps 2 and 3 to correct this sentence.
4. 移動游標到第二個--->標記的行。

---> 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.

5. When you are comfortable appending text move to lesson 1.6.
5. 當你正確添加了文字後,請移步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!!
!! 注: 執行以下步驟之前,請讀完全節!!

1. Exit this tutor as you did in lesson 1.2: :q!
Or, if you have access to another terminal, do the following there.
1. 像1.2節一樣,退出本教程: :q!
或者,你也可以訪問其它的終端,並執行以下幾步。

2. At the shell prompt type this command: vim tutor <ENTER>
'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.
2. 在shell提示符下,鍵入此命令: vim tutor <enter>
'vim' 是要啟動的vim編輯器,‘tutor'是編輯的檔名。該檔案將被編輯修改。

3. Insert and delete text as you learned in the previous lessons.
3. 按照你在前幾節你所學到的插入、刪除文字。

4. Save the file with changes and exit Vim with: :wq <ENTER>
4. 儲存對檔案的修改,並退出vim: :wq <enter>

5. If you have quit vimtutor in step 1 restart the vimtutor and move down to
the following summary.
5. 如果你在步驟1中退出了本教程,啟動本教程並移步到以的總結。

6. After reading the above steps and understanding them: do it.
6. 閱讀完以下幾步後,理解並執行它們。

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Lesson 1 SUMMARY
課程1 的 總結


1. The cursor is moved using either the arrow keys or the hjkl keys.
h (left) j (down) k (up) l (right)
1. 可以使用游標鍵或者hjkl鍵移動游標
h (左移) j (下移) k (上移) l (右移)

2. To start Vim from the shell prompt type: vim FILENAME <ENTER>
2. 從sheel提示符啟動VIM,請鍵入:vim FILENAME <ENTER>

3. To exit Vim type: <ESC> :q! <ENTER> to trash all changes.
OR type: <ESC> :wq <ENTER> to save the changes.
3. 要退出VIM: <ESC> :q! <ENTER> 放棄所有修改。
或者鍵入: <ESC> :wq <ENTER> 儲存所有的修改。

4. To delete the character at the cursor type: x
4. 刪除游標處的一個字元: x

5. To insert or append text type:
i type inserted text <ESC> insert before the cursor
A type appended text <ESC> append after the line
5. 插入或者追加文字:
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 以刪除一個單詞.**

1. Press <ESC> to make sure you are in Normal mode.
1. 按下 <ESC> 以確保你牌正常模式。

2. Move the cursor to the line below marked --->.
2. 移動游標到以下以--->標記的行。

3. Move the cursor to the beginning of a word that needs to be deleted.
3. 移動游標到需要刪除的單詞頭。

4. Type dw to make the word disappear.
4. 鍵入 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.

5. Repeat steps 3 and 4 until the sentence is correct and go to Lesson 2.2.
5. 重新步驟3到4,直到語句正確,然後移步2.2節。


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Lesson 2.2: MORE DELETION COMMANDS
2.2節:其它的刪除命令


** Type d$ to delete to the end of the line. **
** 鍵入 d$ 以刪除游標到行尾間處的字元。**`

1. Press <ESC> to make sure you are in Normal mode.
1. 按下 <ESC> 以確保你處於正常模式。

2. Move the cursor to the line below marked --->.
2. 移動游標到以下以--->標記的行。

3. Move the cursor to the end of the correct line (AFTER the first . ).
3. 移動游標到正確行的末端(在第一個.號後)。

4. Type d$ to delete to the end of the line.
4. 鍵入 d$ 以刪除到行尾。

---> Somebody typed the end of this line twice. end of this line twice.


5. Move on to Lesson 2.3 to understand what is happening.
5. 移動到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. **

1. Move the cursor to the start of the line marked ---> below.

2. Type 2w to move the cursor two words forward.

3. Type 3e to move the cursor to the end of the third word forward.

4. Type 0 (zero) to move to the start of the line.

5. Repeat steps 2 and 3 with different numbers.

---> This is just a line with words you can move around in.

6. Move on to Lesson 2.5.

** 在物件前鍵入重複的次數.**

1. 移動游標到以下以--->標記的行。

2. 鍵入 2w 以使游標向前移動兩個單詞。

3. 鍵入 3e 以使游標向前移動到第三個單詞尾。

4. 鍵入 0 移動到行首。

5. 使用不同 的數字重複步驟2到3.

---> This is just a line with words you can move around in.

6. 移步到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 數字 物件

1. Move the cursor to the first UPPER CASE word in the line marked --->.
1. 移動游標到以下以--->標記的行的第一個大寫單詞處。

2. Type d2w to delete the two UPPER CASE words
2. 鍵入 d2w 以刪除2個大寫 單詞。

3. Repeat steps 1 and 2 with a different count to delete the consecutive
UPPER CASE words with one command
3. 用不同的計數重複步驟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輕鬆刪除一整行。

1. Move the cursor to the second line in the phrase below.
2. Type dd to delete the line.
3. Now move to the fourth line.
4. Type 2dd to delete two lines.
1. 移動移動到以以下短語的第二行。
2. 鍵入 dd 以刪除行。
3. 現在移動到第四行。
4. 鍵入 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 是修復一整行.**

1. Move the cursor to the line below marked ---> and place it on the
first error.
2. Type x to delete the first unwanted character.
3. Now type u to undo the last command executed.
4. This time fix all the errors on the line using the x command.
5. Now type a capital U to return the line to its original state.
6. Now type u a few times to undo the U and preceding commands.
7. Now type CTRL-R (keeping CTRL key pressed while hitting R) a few times
to redo the commands (undo the undo's).
1. 移動游標到以--->標記的行,定位到第一處錯誤。
2. 鍵入 x 以刪除第一個不要的字元。
3. 現在 鍵入 u 以恢復最後執行的命令。
4. 這次用x命令修復該行的所有錯誤。
5. 現在鍵入一個大寫的 U 以回到行的原始狀態。
6。現在按幾次 u 以恢復U 和之間的命令。
7. 現在 按幾次 CTRL+R(按住CTRL同時敲擊R),以撤消恢復命令(與u命令相反)。

---> Fiix the errors oon thhis line and reeplace them witth undo.

8. These are very useful commands. Now move on to the Lesson 2 Summary.
8. 這些都是非常有用的命令。現在移步到第2課的總結。



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Lesson 2 SUMMARY
第2課總結


1. To delete from the cursor up to the next word type: dw
2. To delete from the cursor to the end of a line type: d$
3. To delete a whole line type: dd
1. 刪除游標到下一個單詞: dw
2. 刪除游標到行尾: d$
3. 刪除整行: dd

4. To repeat a motion prepend it with a number: 2w
4. 預置數字以重複物件: 2w
5. 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.
5. 更改命令的格式:
操作碼 [數字] 物件

6. To move to the start of the line use a zero: 0
6. 用0移動到行首: 0

7. 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-R
7. 恢復之前的動作,鍵入: u (小寫)
恢復對一行的所有改變,鍵入:U(大寫)
恢復恢復,鍵入: CTRL-R

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Lesson 3.1: THE PUT COMMAND
3.1節:PUT命令


** Type p to put previously deleted text after the cursor. **
**輸入 p 以在游標處貼上先前刪除的文字.**

1. Move the cursor to the first ---> line below.
1. 移動游標到以下以--->標記的行。

2. Type dd to delete the line and store it in a Vim register.
2. 輸入 dd 以刪除該行,該行會被儲存至VIM暫存器中。

3. Move the cursor to the c) line, ABOVE where the deleted line should go.
3. 移動游標到c)行,即被刪除行要到達的前行。

4. Type p to put the line below the cursor.
4. 鍵入 p 將那行貼上到游標之下。

5. Repeat steps 2 through 4 to put all the lines in correct order.
5. 重複步驟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 以替換游標處的字元。**

1. Move the cursor to the first line below marked --->.
1.移動游標到以--->標記的行。

2. Move the cursor so that it is on top of the first error.
2.移動游標到第一個錯誤。

3. Type r and then the character which should be there.
3.鍵入 r和要更正的字元。 

4. Repeat steps 2 and 3 until the first line is equal to the second one.
4.重複步驟2和3,直到一二行相同。

---> Whan this lime was tuoed in, someone presswd some wrojg keys!
---> When this line was typed in, someone pressed some wrong keys!

5. Now move on to Lesson 3.3.
5.現在移動到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。**

1. Move the cursor to the first line below marked --->.
1.移動游標到以--->標記的行。

2. Place the cursor on the u in lubw.
2.定位游標至 lubw 的 u 上。

3. Type ce and the correct word (in this case, type ine ).
3.鍵入 ce 和 正確的單詞(本例中,應該鍵入 ceine).

4. Press <ESC> and move to the next character that needs to be changed.
4.按<esc>,並移動到下一個需要更改的字元。

5. Repeat steps 3 and 4 until the first sentence is the same as the second.
5.重複步驟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 命令一樣,更改操作碼也使用相同的物件。

1. The change operator works in the same way as delete. The format is:

c [number] motion
1. 更改操作碼的用法與刪除操作碼相同,格式為:
c [number] motion

2. The motions are the same, such as w (word) and $ (end of line).
2.所有的物件是相同的,例如w(單詞)、$(行尾)。

3. Move to the first line below marked --->.
移動到以下以--->標記的第一行。

4. Move the cursor to the first error.
4.移動游標到第一處錯誤。

5. Type c$ and type the rest of the line like the second and press <ESC>.
5.鍵入 c$ 和 餘下的同第二行相同的字等符,並按下<ESC>。

---> 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課總結 


1. 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).
1. 要貼上剛剛刪除的文字,鍵入 p.這會把被刪文字貼上到游標之後(如果某行被刪,它會被貼上到游標之後的一行)。

2. To replace the character under the cursor, type r and then the
character you want to have there.
2.要替換游標處的字元,鍵入 r 和要插入的字元。

3. 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.
3.更改操作碼允許你更改從游標到物件定義處。例如:鍵入 ce 以更改游標到詞尾,鍵入c$會更改游標到行尾。

4. The format for change is:

c [number] motion
4.更改的格式:
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!!
注:執行任何一步前請讀完本課。

1. 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.
1.按住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')

2. Press G to move you to the bottom of the file.
Type gg to move you to the start of the file.
2.按 G 以移動到檔案底。
鍵入 gg 以移動到檔案首。

3. 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.
3.鍵入你之前所在 的行號,然後鍵入G。
這樣你會返回到你之前,即你按CTRL-G時的那一行。

4. If you feel confident to do this, execute steps 1 through 3.
4.如果你有信心去做它,請執行1到3步。

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Lesson 4.2: THE SEARCH COMMAND
4.2節:搜尋命令


** Type / followed by a phrase to search for the phrase. **
**按 / 並接一個要搜尋的短語。**

1. In Normal mode type the / character. Notice that it and the cursor
appear at the bottom of the screen as with the : command.
1.在正常模式,鍵入 / 字母。注意,像:命令一樣,游標會出現在螢幕底

2. Now type 'errroor' <ENTER>. This is the word you want to search for.
2.現在,鍵入 'errroor'<ENTER>.這是你想要搜尋的單詞。
3. To search for the same phrase again, simply type n .
To search for the same phrase in the opposite direction, type N .
3.想再次搜尋相同的短語,簡單的鍵入 n.
3.想再次搜尋相同的短語並以相反的方向,鍵入 N.

4. To search for a phrase in the backward direction, use ? instead of / .
4.要反向搜尋一個短語,使用?替換/.

5. 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.
5.要返回之前的位置,鍵入 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 }.**

1. Place the cursor on any (, [, or { in the line below marked --->.
1.在以--->標記的行中,將游標定位到任一的(,[,{.

2. Now type the % character.
2.現在按下 %字元。

3. The cursor will move to the matching parenthesis or bracket.
3.將游標移動到匹配的括號上。

4. Type % to move the cursor to the other matching bracket.
4.按 % 以移動游標到其它的匹配括號。

5. Move the cursor to another (,),[,],{ or } and see what % does.
5.移動游標到 另外的(,),[,],{ 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 :s/old/new/g to substitute 'new' for 'old'. **
**鍵入 :s/old/new/g 以用’new'替換‘old’。**

1. Move the cursor to the line below marked --->.
1.移動游標到以下以--->標記的行。

2. Type :s/thee/the <ENTER> . Note that this command only changes the
first occurrence of "thee" in the line.
2.鍵入 :s/thee/the <ENTER>.注意此命令僅會更改本行的第一例"thee".

3. Now type :s/thee/the/g . Adding the g flag means to substitute
globally in the line, change all occurrences of "thee" in the line.
3.現在 鍵入 :s/three/the/g. 加入的 g 標誌 意味著 會替換本行所有的
“thee".

---> thee best time to see thee flowers is in thee spring.


4. To change every occurrence of a character string between two lines,
type :#,#s/old/new/g where #,# are the line numbers of the range
of lines where the substitution is to be done.
Type :%s/old/new/g to change every occurrence in the whole file.
Type :%s/old/new/gc to find every occurrence in the whole file,
with a prompt whether to substitute or not.
4. 要更改兩行間的所有的匹配字串:
type :#,#s/old/new/g 其中,#,#是要更改的行號的範圍
Type :%s/old/new/g 更改全檔案中的所有事件。
Type :%s/old/new/gc 更改全檔案中的所有事件,並給出替換與否的提示。 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Lesson 4 SUMMARY
第4課總結

1. CTRL-G displays your location in the file and the file status.
G moves to the end of the file.
number G moves to that line number.
gg moves to the first line.
1. CTRL-G 顯示 當前檔案位置和狀態。
G 移動到檔案尾。
數字 G 移動到某行。
gg 移動到檔案頭。

2. Typing / followed by a phrase searches FORWARD for the phrase.
Typing ? followed by a phrase searches BACKWARD for the phrase.
After a search type n to find the next occurrence in the same direction
or N to search in the opposite direction.
CTRL-O takes you back to older positions, CTRL-I to newer positions.
2. 鍵入 / ,接上要向前搜尋的短語。
鍵入 ? 接上要向後搜尋的短語
搜尋後,按n 以相同的方向搜尋下一事件,按N以相反的方向搜尋。
CTRL-O 使你返回到以前的位置,CTRL-I 回到以後的位置 。

3. Typing % while the cursor is on a (,),[,],{, or } goes to its match.
3.鍵入 % 時括號上的游標會匹配自己的括號。

4. To substitute new for the first old in a line type :s/old/new
To substitute new for all 'old's on a line type :s/old/new/g
To substitute phrases between two line #'s type :#,#s/old/new/g
To substitute all occurrences in the file type :%s/old/new/g
To ask for confirmation each time add 'c' :%s/old/new/gc
4. 在一行中以new替換old. :s/old/new
在一行中以new替換所有的old :s/old/new/g
在#到#兩行間,以new 替換所有的old :#,#s/old/new/g
替換檔案中的所有事件 :%s/old/new/g
每次替換前確認,增加‘c’' :%s/old/new/gc

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Lesson 5.1: HOW TO EXECUTE AN EXTERNAL COMMAND
5.1節:怎樣執行外部命令


** Type :! followed by an external command to execute that command. **
** 按 :! 並加上要執行的外部命令。××
1. Type the familiar command : to set the cursor at the bottom of the
screen. This allows you to enter a command-line command.
1. 鍵入類似的命令: 使游標處於螢幕底。這允許你鍵入一個命令列。

2. Now type the ! (exclamation point) character. This allows you to
execute any external shell command.
2. 現在鍵入 ! 字元。這允許你執行一個任何外部的shell命令

3. As an example type ls following the ! and then hit <ENTER>. This
will show you a listing of your directory, just as if you were at the
shell prompt. Or use :!dir if ls doesn't work.
3. 作為一個例子,鍵入 ls 接一個!,然後敲擊<enter>.這會顯示一個你的目錄,
就像你在一個shell提示符一樣。或者 使用 :!dir (如果 ls不起作用的話)。

NOTE: It is possible to execute any external command this way, also with
arguments.
注: 通過這種方式執行任何的外部命令是可能的,同樣可以跟引數。

NOTE: All : commands must be finished by hitting <ENTER>
From here on we will not always mention it.
注: 所有的 : 命令必須以敲擊<enter>結束。
從這裡開始,我們不會問題提及這些問題。

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Lesson 5.2: MORE ON WRITING FILES
5.2節:其它的寫檔案命令

** To save the changes made to the text, type :w FILENAME. **
**要儲存對文字作的改動,鍵入 :w FILENAME.**

1. Type :!dir or :!ls to get a listing of your directory.
You already know you must hit <ENTER> after this.
1. 鍵入 :!dir or :!ls 以得到你的目錄的清單。
你已經 知道了你必須在這句後 敲擊<enter>.
2. Choose a filename that does not exist yet, such as TEST.
2. 選擇一個不存在的檔名,如TEST。

3. Now type: :w TEST (where TEST is the filename you chose.)
3. 現在 鍵入 : :w TEST (其中的TEST是你選擇的檔名)。

4. This saves the whole file (the Vim Tutor) under the name TEST.
To verify this, type :!dir or :!ls again to see your directory.
4. 這會以TEST的名字 儲存全部檔案(即這個 VIM教程)。
要確認之,請鍵入 :!dir or :!ls 以檢視你的目錄。

NOTE: If you were to exit Vim and start it again with vim TEST , the file
would be an exact copy of the tutor when you saved it.
注:如果你之前退出了VIM並以vim TEST再次啟動了它,這個檔案就會是你儲存時的教
程的副本。

5. Now remove the file by typing (MS-DOS): :!del TEST
or (Unix): :!rm TEST
5. 現在鍵入以下命令刪除這個檔案:
(MS-DOS): :!del TEST
or (Unix): :!rm TEST


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Lesson 5.3: SELECTING TEXT TO WRITE
5.3節:選擇要寫的文字

** To save part of the file, type v motion :w FILENAME **
** 要儲存部分檔案,鍵入 v 物件 :w FILENAME **

1. Move the cursor to this line.
1. 移動游標到此行。

2. Press v and move the cursor to the fifth item below. Notice that the
text is highlighted.
2. 按 v 並移動 游標到 以下的第5項。 注意這些文字會珵高亮。

3. Press the : character. At the bottom of the screen :'<,'> will appear.
3. 按 :字元。在螢幕底會顯示 :'<,'> will appear.

4. Type w TEST , where TEST is a filename that does not exist yet. Verify
that you see :'<,'>w TEST before you press Enter.
4. 按 w TEST ,其中 TEST 是一個不存在 的檔案。
確認你按<enter>前你看到了:'<,'>w TEST.

5. Vim will write the selected lines to the file TEST. Use :!dir or !ls
to see it. Do not remove it yet! We will use it in the next lesson.
5. vim 會把選定的行進檔案TEST中,使用 :!dir or !ls 作檢查。先別刪除它!
我們會下節使用它。

NOTE: Pressing v starts Visual selection. You can move the cursor around
to make the selection bigger or smaller. Then you can use an operator
to do something with the text. For example, d deletes the text.
注: 按下v 開始選擇選擇。你可以將游標移動到其它地方以使選擇的區變大或者 變小。
然後你可使用操作碼對文字做一些事。比如,d 刪除檔案。

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Lesson 5.4: RETRIEVING AND MERGING FILES
5.4節:恢復和合並檔案


** To insert the contents of a file, type :r FILENAME **
** 要插入一個檔案的內容鍵入:r FILENAME **

1. Place the cursor just above this line.

NOTE: After executing Step 2 you will see text from Lesson 5.3. Then move
DOWN to see this lesson again.
1.只需將游標放到這一行。
注: 執行第二步後你會看到5.3節的內容。然後下移並再次檢視這節。

2. Now retrieve your TEST file using the command :r TEST where TEST is
the name of the file you used.
The file you retrieve is placed below the cursor line.
2. 現在 恢復 你的TEST檔案,使用命令 :r TEST 其中,TEST 是你使用的檔案。
你要恢復的檔案將被放置在游標行下面。

3. To verify that a file was retrieved, cursor back and notice that there
are now two copies of Lesson 5.3, the original and the file version.
3. 要確認檔案被恢復了,用游標返回,注意這裡有兩5.3節的副本,原本的檔案版。

NOTE: You can also read the output of an external command. For example,
:r !ls reads the output of the ls command and puts it below the
cursor.
注: 你可能會閱讀外部命令的輸出。如 :r !ls 讀入ls命令的輸出並將其放置到
游標下。`


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Lesson 5 SUMMARY
第5課總結


1. :!command executes an external command.

Some useful examples are:
(MS-DOS) (Unix)
:!dir :!ls - shows a directory listing.
:!del FILENAME :!rm FILENAME - removes file FILENAME.
1. :!command 執行外部命令

一些有用的例子:
(MS-DOS) (Unix)
:!dir :!ls - 顯示目錄清單
:!del FILENAME :!rm FILENAME - 移除 FILENAME檔案。

2. :w FILENAME writes the current Vim file to disk with name FILENAME.
2. :w FILENAME 將當前的vim 檔案以FILENAME 檔名寫進磁碟 。

3. v motion :w FILENAME saves the Visually selected lines in file
FILENAME.
3. v 物件 :w FILENAME 儲存選定選擇行到FILENAME 檔案。

4. :r FILENAME retrieves disk file FILENAME and puts it below the
cursor position.
4. :r FILENAME 恢復磁碟檔案FILENAME到游標下。

5. :r !dir reads the output of the dir command and puts it below the
cursor position.
5. :r !dir 讀取dir命令的輸出並貼上到游標下。


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Lesson 6.1: THE OPEN COMMAND
6.1節:OPEN 命令


** Type o to open a line below the cursor and place you in Insert mode. **
** 鍵入 o 以在游標開啟一行,並置於插入模式。**

1. Move the cursor to the line below marked --->.
1. 移動游標到以--->標記的行。

2. Type the lowercase letter o to open up a line BELOW the cursor and place
you in Insert mode.
2. 鍵入 小寫字母 o 以在游標下插入一行,並置於插入模式。

3. Now type some text and press <ESC> to exit Insert mode.
3. 現在 鍵入 一些文字,並按<esc>以退出插入模式。 

---> After typing o the cursor is placed on the open line in Insert mode.

4. To open up a line ABOVE the cursor, simply type a capital O , rather
than a lowercase o. Try this on the line below.
4. 要在游標前插入一行,只需鍵入 大寫字母 O,而非小寫字母 o,在下一行試試。

---> Open up a line above this by typing O while the cursor is on this line.




~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Lesson 6.2: THE APPEND COMMAND
6.2: 追加命令

** Type a to insert text AFTER the cursor. **
**鍵入 a 以在游標後插入文字。**

1. Move the cursor to the start of the line below marked --->.
1. 移動 下面以--->標記的行首。

2. Press e until the cursor is on the end of li .
2. 按 e 直到 游標在li 尾。

3. Type an a (lowercase) to append text AFTER the cursor.
3. 銨 一個 a(小寫) 以追加文字到游標後。

4. Complete the word like the line below it. Press <ESC> to exit Insert
mode.
4. 按照下一行完成這個單詞。按<esc>退出插入模式。

5. Use e to move to the next incomplete word and repeat steps 3 and 4.
5. 使用 e 移動到未完成的單詞,並重復步驟3和4.

---> This li will allow you to pract appendi text to a line.
---> This line will allow you to practice appending text to a line.

NOTE: a, i and A all go to the same Insert mode, the only difference is where
the characters are inserted.
注: a,i 和A 都會進入插入模式,僅有的不同是字元在哪裡插入。

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Lesson 6.3: ANOTHER WAY TO REPLACE
6.3節: 以別一種方式替換


** Type a capital R to replace more than one character. **
** 鍵入 大寫 R 以替換 更多的字元而非一個。**

1. Move the cursor to the first line below marked --->. Move the cursor to
the beginning of the first xxx .
1. 移動游標到以---》標記的第一行。移動游標到第一個XXX。

2. Now press R and type the number below it in the second line, so that it
replaces the xxx .
2. 現在 按下 R 並鍵入 在第二行顯示的數字,以其替換xxx.

3. Press <ESC> to leave Replace mode. Notice that the rest of the line
remains unmodified.
3. 按下<ESC> 以 離開替換模式。注意 剩餘的行仍沒有改變。

4. Repeat the steps to replace the remaining xxx.
4. 重複以上步驟以替換剩餘的XXX。

---> Adding 123 to xxx gives you xxx.
---> Adding 123 to 456 gives you 579.

NOTE: Replace mode is like Insert mode, but every typed character deletes an
existing character.
注: 替換模式下類似於插入模式,但是鍵入字元會刪除已經存在的字元。

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Lesson 6.4: COPY AND PASTE TEXT
6.4: 複製貼上文字


** Use the y operator to copy text and p to paste it **
** 用y 操作碼來複制文字,以 p 貼上此文字.**

1. Go to the line marked with ---> below and place the cursor after "a)".
1. 移動到以--->標記的行並定位到“a)”後。

2. Start Visual mode with v and move the cursor to just before "first".
2. 以v 開啟選擇模式,移動游標到“first”前。

3. Type y to yank (copy) the highlighted text.
3. 按 y 以複製高亮的文字。

4. Move the cursor to the end of the next line: j$
4. 移動 游標到下一行的:j$

5. Type p to put (paste) the text. Then type: a second <ESC> .
5. 按p 以貼上文字,然後鍵入:a second <esc>.

6. Use Visual mode to select " item.", yank it with y , move to the end of
the next line with j$ and put the text there with p .
6. 使用選擇模式以選擇” item。“,以y複製之,以j$移動到下行並以p貼上到那裡。

---> a) this is the first item.
b)

NOTE: you can also use y as an operator; yw yanks one word.
注: 你可能會使用y 作操作碼;yw 複製一個單詞。
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Lesson 6.5: SET OPTION
6.5節:設定選項


** Set an option so a search or substitute ignores case **
** 設定搜尋和替換時忽略大小寫的選項**

1. Search for 'ignore' by entering: /ignore <ENTER>
Repeat several times by pressing n .
1. 搜尋’ignore‘ ,鍵入 : /ignore <enter>
重複按n幾次。

2. Set the 'ic' (Ignore case) option by entering: :set ic
2. 設定 ’ic‘(忽略大小寫)選項,鍵入: :set ic

3. Now search for 'ignore' again by pressing n
Notice that Ignore and IGNORE are now also found.
3. 現在 以n再次搜尋'ignore'.
注意,Ignore and IGNORE都可以被搜到。

4. Set the 'hlsearch' and 'incsearch' options: :set hls is
4. 設定選項'hlsearch' and 'incsearch': set hls is

5. Now type the search command again and see what happens: /ignore <ENTER>
5. 同在鍵入搜尋命令,看看發生 了什麼: /ignore <enter>

6. To disable ignoring case enter: :set noic
6. 要禁止忽略大小寫,鍵入: :set noic 

NOTE: To remove the highlighting of matches enter: :nohlsearch 
注意: 要刪除高亮匹配,鍵入: :nohlsearch
NOTE: If you want to ignore case for just one search command, use \c
in the phrase: /ignore\c <ENTER>
注: 如果 你只是想在某次搜尋命令時忽略大小寫,在短語後加上\c: /ignore\c <enter>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Lesson 6 SUMMARY
第6課總結

1. Type o to open a line BELOW the cursor and start Insert mode.
Type O to open a line ABOVE the cursor.
1. 按o 以插入一行,在游標後,並進入插入模式。
按O 以在游標前插入一行。

2. Type a to insert text AFTER the cursor.
Type A to insert text after the end of the line.
2. 按a 以在游標後插入文字。
按A在行尾插入文字。

3. The e command moves to the end of a word.
3. e命令使游標移動到單詞尾。

4. The y operator yanks (copies) text, p puts (pastes) it.
4. y操作碼 複製文字,p 貼上此文字。

5. Typing a capital R enters Replace mode until <ESC> is pressed.
5. 調入大寫字母R,進入替換模式,直到<esc>按下。

6. Typing ":set xxx" sets the option "xxx". Some options are:
'ic' 'ignorecase' ignore upper/lower case when searching
'is' 'incsearch' show partial matches for a search phrase
'hls' 'hlsearch' highlight all matching phrases
You can either use the long or the short option name.
6. 鍵入":set xxx" 以設定選項 "xxx". 一些選項:
'ic' 'ignorecase' 搜尋時忽略大小寫
'is' 'incsearch' 部分顯示匹配的搜尋短語。
'hls' 'hlsearch' 高亮所有匹配的短語
你可選用長的或者短的選項名。

7. Prepend "no" to switch an option off: :set noic
7. 前置”no"以關閉選項: :set noic 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Lesson 7.1: GETTING HELP
7.1節:使用幫助


** Use the on-line help system **
**使用線上幫助系統**

Vim has a comprehensive on-line help system. To get started, try one of
these three:
- press the <HELP> key (if you have one)
- press the <F1> key (if you have one)
- type :help <ENTER>
vim 有一個廣泛的線上幫助系統。要啟用之,可試試這三種之一:
- 按 <help> (如果你有)
- 按 <F1> (如果你有)
- 按 :help <enter>

Read the text in the help window to find out how the help works.
Type CTRL-W CTRL-W to jump from one window to another.
Type :q <ENTER> to close the help window.
閱讀help視窗以檢視help是如何進行的。
Type CTRL-W CTRL-W 從一個視窗跳轉到另一個視窗。
Type :q <ENTER> 關閉幫助 視窗。

You can find help on just about any subject, by giving an argument to the
":help" command. Try these (don't forget pressing <ENTER>):

:help w
:help c_CTRL-D
:help insert-index
:help user-manual
你可以通過為":help"給一個引數找到任何主題的幫助,試試這些(別忘了<enter>)
:help w
:help c_CTRL-D
:help insert-index
:help user-manual
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Lesson 7.2: CREATE A STARTUP SCRIPT
7.2節:建立啟動指令碼


** Enable Vim features **
**啟用VIM特性**
Vim has many more features than Vi, but most of them are disabled by
default. To start using more features you have to create a "vimrc" file.
VIM 擁有比vi更多的特性,但是大多數是被預設禁止的。要使用更多的
特性,你可建立“vimrc”檔案。

1. Start editing the "vimrc" file. This depends on your system:
:e ~/.vimrc for Unix
:e $VIM/_vimrc for MS-Windows
1. 開始編輯“vimrc”檔案,這依賴於你的系統。
:e ~/.vimrc for Unix
:e $VIM/_vimrc for MS-Windows
2. Now read the example "vimrc" file contents:
:r $VIMRUNTIME/vimrc_example.vim
2. 現在閱讀下“vimrc”檔案的例子:
:r $VIMRUNTIME/vimrc_example.vim

3. Write the file with:儲存檔案
:w

The next time you start Vim it will use syntax highlighting.
You can add all your preferred settings to this "vimrc" file.
For more information type :help vimrc-intro
下次,你啟動VIM後,它會使語法高亮,你可以在“vimrc”中新增所有你喜歡的
設定。
更多資訊請鍵入 :help vimrc-intro 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Lesson 7.3: COMPLETION
7.3節:補齊

** Command line completion with CTRL-D and <TAB> **
××使用CTRL-D和<TAB>使命令列補齊××

1. Make sure Vim is not in compatible mode: :set nocp
1. 確保VIM 處於非相容模式: :set nocp 

2. Look what files exist in the directory: :!ls or :!dir
2. 看看目錄下有什麼檔案存在: :!ls or :!dir 

3. Type the start of a command: :e
3. 鍵入命令的開始部分: :e 

4. Press CTRL-D and Vim will show a list of commands that start with "e".
4. 按 CTRL-D ,VIM會顯示以“e”開頭的清單。

5. Press <TAB> and Vim will complete the command name to ":edit".
5. 按下<TAB>,VIM會以“:edit"補齊命令名。

6. Now add a space and the start of an existing file name: :edit FIL
6. 現在 新增一個空格和己存的檔名頭部: :edit FIL

7. Press <TAB>. Vim will complete the name (if it is unique).
7. 按<tab>,vim會完成餘下的檔名(如果它是獨有的話)。

NOTE: Completion works for many commands. Just try pressing CTRL-D and
<TAB>. It is especially useful for :help .
注:補齊針對大多數命令有效,只需按CTRL-R和<TAB>.特別是對 :help 非常有用 。

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Lesson 7 SUMMARY
第七課總結

1. Type :help or press <F1> or <Help> to open a help window.
1. 鍵入 :help 或 <F1> 或<help>以開啟幫助視窗

2. Type :help cmd to find help on cmd .
2. 鍵入 :help cmd 以找出關於cmd的幫助 。

3. Type CTRL-W CTRL-W to jump to another window
3. 鍵入 CTRL-W 以跳轉到另一視窗。

4. Type :q to close the help window
4. 鍵入 :q 以關閉幫助視窗。

5. Create a vimrc startup script to keep your preferred settings.
5.建立 vimrc 啟動指令碼以儲存你喜歡的設定。

6. When typing a : command, press CTRL-D to see possible completions.
Press <TAB> to use one completion.
6. 當鍵入 :command 時,按下CTRL-D 以檢視可能的補齊。
按<tab>使用其中一個補齊。







~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

This concludes the Vim Tutor. It was intended to give a brief overview of
the Vim editor, just enough to allow you to use the editor fairly easily.
It is far from complete as Vim has many many more commands. Read the user
manual next: ":help user-manual".
本文總結了vim教程。它原本給出了VIM編輯器的簡短的概要,只能足以讓你很容易地
使用編輯器。這遠沒有完成,因為VIM在如此眾多的命令。請閱讀下面的使用者手冊:
:help user-manual

For further reading and studying, this book is recommended:
Vim - Vi Improved - by Steve Oualline
Publisher: New Riders
The first book completely dedicated to Vim. Especially useful for beginners.
There are many examples and pictures.
See 
http://iccf-holland.org/click5.html


要進一步的閱讀和學習,我們推薦這本書:
Vim - Vi Improved -作者Steve Oualline
出版社:New Riders
第一本書專門針對 Vim. 特別適合 新手.
其中有許多例項和圖示。
See http://iccf-holland.org/click5.html


This book is older and more about Vi than Vim, but also recommended:
Learning the Vi Editor - by Linda Lamb
Publisher: O'Reilly & Associates Inc.
It is a good book to get to know almost anything you want to do with Vi.
The sixth edition also includes information on Vim.

這本書比較老並且主要內容是VI而非vim,但是仍值得推薦:
Learning the Vi Editor - by Linda Lamb
出版社: O'Reilly & Associates Inc.
它是一本能告訴你你想利用VI做的幾乎所有事情的好書。
此書的第三版也包含了有關VIM的內容。


This tutorial was written by Michael C. Pierce and Robert K. Ware,
Colorado School of Mines using ideas supplied by Charles Smith,
Colorado State University. E-mail: 
[email protected]
.
Modified for Vim by Bram Moolenaar.

本教程由科羅拉多礦業學院的Michael C. Pierce 和 Robert K. Ware編寫,同時Charles Smith 提供了很多創意。
E-mail: [email protected].
Bram Moolenaar 為VIM對本教程作了修訂。

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
=====================================================
下面是我的補充,絕大部分內容取自:
vi improved簡介
[email protected]
(滇狐)
清華大學軟體學院
北大linux俱樂部
====================================================
CTRL+F:往下翻頁
CTRL+B:往上翻頁

的輸入:使用CTRL+V,CTRL+M
行的拼接:
在選擇模式選中要拼接的行:ggvG
輸入: :'<,'>j<enter>
注:普通的j用於拼接單行。
列操作:
選中全文的第一列
按gg跳至開頭
按CTRL——V進入列選擇狀態:visula block
按G到末尾
將每行的第一列變為大寫
按U將選中內容變大寫
按u將選中內容變小寫
按~將大小翻轉。
列操作:在第行前加一個星號和空格:
選中第一列
按I進入插入狀態
輸入:*<space><ESC>
選中前兩列後按x,可時行列刪除
巨集的錄製:將所有偶數行後加入OK!
按gg進入第一行
按qm進入巨集錄製
按j$進入第二行尾
按aok!以輸入ok!
按<esc>返回
按j到下一行
按q結束巨集錄製
巨集的播放:(接上面的步驟)
單次播放:
按下@m,執行m暫存器中的巨集
可以發現第4行中的尾已經加入了ok!
多次播放:
按下[email protected],這裡重複播放100次巨集。
點號(重複上一次命令):
將第行尾加一個感嘆號
按ggA!以在第一行新增感嘆號
按<esc>j以到下一行。
按.表示重複前一個操作,即在執行A!<esc>以在行尾新增一個感嘆號。
反覆按j.j.j.j.j.
:%s/$/!/g



========================.virc for beginners==================
基本設定
set nocp 設定不相容模式
set ru 開啟狀態列標尺
set hls 搜尋時高亮顯示找到的文字
set is 遞進搜尋
syntax on 開啟關鍵字上色
set backspace=indent,eol,start
set whichrap=b,s,<,>,[,]
h,l,~
set sw=4 縮排尺寸4個空格
set ts=4 Tab寬度為4個字元
set et 將所有的TAB替換為空格
C/C++編碼設定
set cin 自動縮排
set ai 還是自動縮排
set cino=:0g0t0(sus
set sm 顯示括號匹配
在console下貼上版式的問題
:set paste
:set nopaste
= 命令重調格式
斷行設定
set lbr 不在單詞中間斷行
圖形介面與字元介面分別設定
if (has("gui_running")) 圖形介面設定
set nowrap 不拆行
set guioptions+=b 水平流動條
colo torte 配色方案
else 字元介面設定
set wrap 拆行
colo ron 配色方案
endif
==========================粘一點點ubuntu置頂中的東西===================
如何找到上次編輯的檔案:
ctrl+O《兩次》 其中的O是大寫
如何複製貼上? 

複製 

方法一:

先ma標記當前位置為a,移動到新的位置,再y`a或者y'a複製從標記位置a到當前位置的內容。`和'的區別:`以字元為單位,'以行為單位。這個方法應該是所有vi都適用的。(如果不對請指正。)

方法二: 按v或V或Ctrl+V進入visual模式,移動游標選擇一段內容,按y(若要使用系統黏貼板,按"+y)。三者的區別: v以字元為單位,V以行為單位,Ctrl+V是塊選擇。這個方法只在VIM下適用。

貼上 

p或P。區別:前者貼上到游標後面,後者貼上到游標前面。

如何在多個檔案中進行替換? 

一般可以用sed或者vim來做。比如要對當前目錄下的*.c檔案進行替換: 方法一:
程式碼:
for i in *.c; do
sed -i -e 's/oldvalue/newvalue/g' $i
done

方法二:
程式碼:
vim *.c
:argdo %s/oldvalue/newvalue/ge | update

相關推薦

30分鐘學會vimvimtutor(雙語

=============================================================================== = 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版 =

30分鐘學會如何使用Shiro(轉

dex user false fin hiberna bean overflow getc mis 本篇內容大多總結自張開濤的《跟我學Shiro》原文地址:http://jinnianshilongnian.iteye.com/blog/2018936我並沒有全部看完,只是

微信小程式30分鐘學會開發小程式(小程式總覽

一.註冊小程式賬號,下載IDE 1.官網註冊https://mp.weixin.qq.com/,並下載IDE。 2.官方文件一向都是最好的學習資料。 注意: (1)註冊賬號之後會有一個appid,新建專案的時候需要填上,不然很多功能是用不了的,比如不能預覽,不能上傳程式碼等等。

【grunt整合30分鐘學會使用grunt打包前端程式碼

grunt 是一套前端自動化工具,一個基於nodeJs的命令列工具,一般用於:① 壓縮檔案② 合併檔案③ 簡單語法檢查 對於其他用法,我還不太清楚,我們這裡簡單介紹下grunt的壓縮、合併檔案,初學,有誤請包涵 準備階段 1、nodeJs環境 因為grunt是基於nodeJs的,所以首先各位需要安裝

30分鐘學會如何使用Shiro

springmvc+mybatis dubbo+zookeeper restful redis分布式緩存 shiro kafka 一、架構要學習如何使用Shiro必須先從它的架構談起,作為一款安全框架Shiro的設計相當精妙。Shiro的應用不依賴任何容器,它也可以在JavaSE下使用。但

分鐘學會 ConstraintLayout 從屬性角度理解布局

uic mem app tor normal add 部分 pla ray ConstraintLayout 在 Android 開發中,我們通常是手寫布局,很少會用拖動來寫布局,雖然 ConstraintLayout 在 I/O 上以拖動來展現了各種功能

30分鐘學會如何使用Shiro(轉)

字段 col inf lan getc 含義 掌握 ide 包含 本文轉自http://www.cnblogs.com/learnhow/p/5694876.html 感謝作者 本篇內容大多總結自張開濤的《跟我學Shiro》原文地址:http://jinnianshilo

小白30分鐘學會網頁采集基礎教程

網頁采集首先,以某個多頁(需要自動翻頁)表格數據的采集為例,先演示一次網頁采集的完整的過程:點擊從頭播放完整動圖演示這裏使用的是八爪魚,依次點擊表格某一行的每個字段,可以自動識別出其他所有數據行,並自動創建循環列表;點擊翻頁按鈕,選擇“循環點擊下一頁”動作,就能自動創建翻頁循環。網頁信息爪取相關的工具有很多,

30分鐘學會iOS 11開發環境xcode 9圖文教程

iOS 11關註微信公眾號【異步圖書】每周送書Xcode是一款功能全面的應用程序,通過此工具可以輕松輸入、編譯、調試並執行Objective-C程序。如果想在Mac上快速開發iOS應用程序,則必須學會使用這個強大的工具的方法。在本文容中,將詳細講解Xcode 9開發工具的基本知識,為讀者步入本書後面知識的學習

30分鐘學會EventBus3.0詳解(一(引入和初始化EventBus3.0 30分鐘學會EventBus3.0詳解(二(EventBus3.0的詳細使用 30分鐘學會EventBus3.0詳解(一(引入和初始化EventBus3.0 30分鐘學會EventBus3.0詳解(二(Ev

分享一下我老師大神的人工智慧教程!零基礎,通俗易懂!http://blog.csdn.net/jiangjunshow 也歡迎大家轉載本篇文章。分享知識,造福人民,實現我們中華民族偉大復興!        

今晚9點:閱碼場線上視訊課程首發內測《20分鐘學會vim工程實戰》

經過長時間自主開發和打磨,閱碼場線上教育平臺www.yomocode.com終於開啟首發內測。由於本次內測強調暴露平臺本身的問題和將平臺測試問題,因此選擇了難度係數最低的vim課程。 課程內容 本課程中,宋寶華老師介紹了10幾年Linux開發過程中,用到的vim真實實踐,包括程

閱碼場線上視訊課程首發內測《20分鐘學會vim工程實戰》

經過長時間自主開發和打磨,閱碼場線上教育平臺www.yomocode.com終於開啟首發內測。由於本次內測強調暴露平臺本身的問題和將平臺測試問題,因此選擇了難度係數最低的vim課程。 課程內容 本課程中,宋寶華老師介紹了10幾年Linux開發過程中,用到的vim真實實踐,包括程

30分鐘學會ES6 (二)

ES6學習系列重點針對ES6中新增特性進行學習,分為兩個章節: 30分鐘學會ES6 (一) 本章節主要學習 let,const,template string,變數解構賦值,函式,Set,Map 30分鐘學會ES6 (二) 本章節主要學習 類 和 模組化 。 30

30分鐘學會ES6 (一)

ES6學習系列重點針對ES6中新增特性進行學習,分為兩個章節: 30分鐘學會ES6 (一) 本章節主要學習 let,const,template string,變數解構賦值,函式,Set,Map 30分鐘學會ES6 (二) 本章節主要學習 類 和 模組化 。 30

開發框架-Shiro-30分鐘學會如何使用Shiro

一、架構 要學習如何使用Shiro必須先從它的架構談起,作為一款安全框架Shiro的設計相當精妙。Shiro的應用不依賴任何容器,它也可以在JavaSE下使用。但是最常用的環境還是JavaEE。下面以使用者登入為例: (1)使用使用者的登入資訊建立令牌 Usern

【grunt第一彈】30分鐘學會使用grunt打包前端程式碼

前言 以現在前端js激增的態勢,一個專案下來幾十個js檔案輕輕鬆鬆對於複雜一點的單頁應用來說,檔案上百簡直是家常便飯,那麼這個時候我們的js檔案應該怎麼處理呢?另外,對於css檔案,又該如何處理呢??這些都是我們實際工作中要遇到的問題,比如我們現在框架使用zepto、backbone、underscore我

30分鐘學會微信公眾號的資料抓取

網路爬蟲實戰之微信公眾號 簡介: 這篇文章主要教大家怎麼獲取一些電腦無法訪問的微信公眾號資料,乾貨滿滿,30分鐘包學會。 實戰 環境 作業系統: win10 python版本: 2.7.3 安裝 抓包工具有很多,

30分鐘學會用scikit-learn的基本回歸方法(線性、決策樹、SVM、KNN和整合方法(隨機森林,Adaboost和GBRT

注:本教程是本人嘗試使用scikit-learn的一些經驗,scikit-learn真的超級容易上手,簡單實用。30分鐘學會用呼叫基本的迴歸方法和整合方法應該是夠了。 本文主要參考了scikit-learn的官方網站 前言:本教程主要使用了numpy的最最基

****30分鐘學會如何使用Shiro

https://www.cnblogs.com/learnhow/p/5694876.html本篇內容大多總結自張開濤的《跟我學Shiro》原文地址:http://jinnianshilongnian.iteye.com/blog/2018936我並沒有全部看完,只是選擇了一

轉:30分鐘學會如何使用Shiro

授權 play 分享 配置文件 3.1 單向 get() 地址 全部 引自:http://www.cnblogs.com/learnhow/p/5694876.html 本篇內容大多總結自張開濤的《跟我學Shiro》原文地址:http://jinnianshilongni