使用動詞和名詞進行文字編輯

考慮應該執行的命令,以某種方式編輯文字的方法之一就是整個句子。

命令是對物件執行的操作。因此它有一個動詞:

:normal i    " insert
:normal a    " append
:normal c    " overwrite
:normal y    " yank (copy)
:normal d    " delete

其中一些詞與 dcy 等物件一起使用。這些物件可以是單詞,行,句子,段落,標籤。可以組合使用這些:

:normal dw    " deletes the text from the position of the cursor to the end of the next word
:normal cw    " deletes the text from the cursor to the end of the next word and
              " enters insert mode

還可以使用修飾符來精確指定執行操作的位置:

:normal diw    " delete inside word. I.e. delete the word in which is the cursor.
:normal ciw    " removes the word, the cursor points at and enters insert mode
:normal ci"    " removes everything between the opening and closing quotes and
               " enters insert mode
:normal cap    " change the current paragraph
:normal ct8    " remove everything until the next number 8 and enter insert mode
:normal cf8    " like above but remove also the number
:normal c/goal " remove everything until the word 'goal' and enter insert mode
:normal ci{    " change everything inside the curly braces

更多資源:

學會說 vim - 動詞,名詞和修飾語!

2014 年學習 Vim:Vim as Language

使用 Speech Grammar 編輯 VimSpeak