Vim常用編輯命令:移動、跳轉到文件中某位置
阿新 • • 發佈:2019-02-14
vi編輯器是Linux和Unix上最基本的文字編輯器,是visual editor的簡稱,工作在字元模式下。由於不需要圖形介面,vi是效率很高的文字編輯器。它在Linux上的地位就像Edit程式在DOS上一樣。它可以執行輸出、刪除、查詢、替換、塊操作等眾多文字操作,而且使用者可以根據自己的需要對其進行定製。Vim是vi的加強版,比vi更容易使用。vi的命令幾乎全部都可以在vim上使用。常用基本命令如下有:
- gg:命令將游標移動到文件開頭
- G:命令將游標移動到文件末尾
- vi編輯器中在命令列模式下輸入G可以直接跳轉到頁面的底部在命令列模式下輸入1G可以跳轉到頁面的頭部位置
- h Move left
- j Move down
- k Move up
- l Move right
- w Move to next word
- W Move to next blank delimited word
- b Move to the beginning of the word
- B Move to the beginning of blank delimted word
- e Move to the end of the word
- E Move to the end of Blank delimited word
- ( Move a sentence back
- ) Move a sentence forward
- { Move a paragraph back
- } Move a paragraph forward
- 0 Move to the begining of the line
- $ Move to the end of the line
- 1G Move to the first line of the file
- G Move to the last line of the file
- nG Move to nth line of the file
- :n Move to nth line of the file
- fc Move forward to c
- Fc Move back to c
- H Move to top of screen
- M Move to middle of screen
- L Move to botton of screen
- % Move to associated ( ), { }, [ ]