2011年3月27日 星期日

第一步:basis 2

在vim中,有四個模式
1.Command-Line mode
   一開始,開始vim時.均由此模式開始操作.
   要編輯資料時,就進入insert mode下(參2)
   或刪除資料時,就輸入刪除指令(參3)  
   for entering commands, e.g. :set number

2.Insert mode
    Use only for typing;(由Command-Line mode下,按

    1.  i : 在游標所在字元前開始輸入文字(insert)。
    2.  I :在行首開始輸入文字。
    3. a:在游標所在字元後開始輸入文字(append)。
    4. A:在行尾開始輸入文字。

    在此模式下,可以編輯,仍可移動遊標

3.刪除資料
  • x:刪除目前遊標所指的字元 (可用u恢復
  • dw:刪除其word
  • cw:cw+insert mode
  • dd:delete  a line at the cursor
  • dw:dd+insert mode
  • r:取代目前的字元(x+i)
ps.可以用10dd
We have discussed about the function of ESC above, ESC can also be used to cancel a command, for example, if you wanna change a word but after typing c, you find out that the cursor is at the wrong position, you can use ESC to cancel the command. =item * Replacement

5.vISUAL SELECTION(可視選擇模式
   一般情況下,你要使用剪下時,可直接使用d,(複製,y);(剪下並進入,insert mode.c)
   但為了提示選區,可以使用v,(V)用強光提示.
  •   在可視選擇模式下
          可用 d,y,c
  • 在非可視選擇模式下
        當你很清楚知道你要的東西時,就不需要進行可視模式下.即可節省時間
    1. d{motion}:剪切motion指令跨過的字元到剪貼簿.如:dw,dfS
    2. y{motion}:複制
    3. c{motion}:同d,但會進入insert mode
    4. cc,yy,dd
    5. D:剪切游標位置到行尾的內容到剪貼薄
    6. Y:複制當行
    7. C:同D,但insert
    8. x:剪切當前字元
    9. s:同x,但insert mode
 **使用多重剪貼簿
     在vim稱為暫存器(register),:reg可以列出當前定義的所有register及內容
(" kyy:複制前行到暫存器k中....其暫存器的命名,最好是用小寫字母

    

沒有留言:

張貼留言