Vim 删除多个单词

标签 vim

早些时候,我想删除 3 个单词,光标在第一个单词内。例如

Vim is the best text editor



将光标放在 h 中的 the 上。我想结束在

Vim is editor



我尝试使用 3diw 来摆脱它们,但这给我留下了

Vim is text editor


istext 之间有 2 个空格。 3daw 工作正常,给我留下了我想要的东西,但我很困惑为什么 3diw 不起作用。我本来希望 3diw3daw 删除相同数量的单词,唯一的区别是 diw 留两个空格而 daw 留一个。

那么为什么 3diw 有这种行为呢?

最佳答案

你不明白 iwaw 之间的区别。使用 [count]diw(内部单词),单词之间的空格也会被计算在内。但它们不会被 aw 计算在内

iw          "inner word", select [count] words (see |word|).
            White space between words is counted too.
            When used in Visual linewise mode "iw" switches to
            Visual characterwise mode.

                            *v_aW* *aW*
aW          "a WORD", select [count] WORDs (see |WORD|).
            Leading or trailing white space is included, but not
            counted.

因此,如果您想在示例中使用 iw ,则需要按 6diw :
1 the
2 " "
3 best
4 " "
5 text
6 " "

关于Vim 删除多个单词,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25229562/

相关文章:

用于组合数字的正则表达式

python - vim 的 python 插件,如 vim-r-plugin

vim - 如何在 Vim 中删除一个单词

linux - 无法安装eclim

debugging - 如何调试 VimL 中的问题?

vim - 如何使用wayland从Vim复制到系统剪贴板而不使用编译的vim `+clipboard`功能标志

c++ - 在 Vim 中添加/追加(前缀/后缀)行

unix - 如何将两个 Vim 命令合二为一(命令不是键绑定(bind))

vim - 按箭头键时,取消 vim 终端模式

vim - 如何在现有窗口中新缓冲区上的Vim中打开帮助文件?