使用动词和名词进行文本编辑
考虑应该执行的命令,以某种方式编辑文本的方法之一就是整个句子。
命令是对对象执行的操作。因此它有一个动词:
:normal i " insert
:normal a " append
:normal c " overwrite
:normal y " yank (copy)
:normal d " delete
其中一些词与 d
,c
,y
等对象一起使用。这些对象可以是单词,行,句子,段落,标签。可以组合使用这些:
: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