我现在从TextMate切换到VIM。我发现^+W在插入模式下非常有用。但是,我不仅要删除游标之前的单词,还要删除游标之后或周围的单词。
我做了一些谷歌搜索,但我唯一能找到的是^+W删除单词前光标。
我现在从TextMate切换到VIM。我发现^+W在插入模式下非常有用。但是,我不仅要删除游标之前的单词,还要删除游标之后或周围的单词。
我做了一些谷歌搜索,但我唯一能找到的是^+W删除单词前光标。
当前回答
重复删除单词时,接受的答案失败,请尝试以下解决方案:
" delete current word, insert and normal modes
inoremap <C-BS> <C-O>b<C-O>dw
noremap <C-BS> bdw
它映射CTRL-BackSpace,也在正常模式下工作。
其他回答
如果要删除游标之前的一定数量的字符,可以使用x。如果要删除游标之后的一定数量的单词,可以使用dw(以3个单词为例,可以使用3dw删除多个单词)。一般来说,如果要删除光标周围的内容,可以使用daw。
你是说像?
dw
我想这只是乌鸦
daw - delete a word
正常模式:
daw : delete the word under the cursor
caw : delete the word under the cursor and put you in insert mode
我不仅要删除光标之前的单词,而且要删除光标之后或周围的单词。
在这种情况下,可以将OP提出的解(即使用<c-w>)与接受的答案结合起来,得到:
inoremap <c-d> <c-o>daw<c-w>
或者(更短的解决方案):
inoremap <c-d> <c-o>vawobd
样例输入:
word1 word2 word3 word4
^------------- Cursor location
输出:
word1 word4