如何配置 vim 以便移动命令将包含下划线和 CamelCase,但完成将忽略它们? [英] How can I configure vim so that movement commands will include underscores and CamelCase, but completion will ignore them?
问题描述
例如,我目前有这个:
set iskeyword-=_
这有使这项工作的效果:
This has the effect of making this work:
foo_bar
如果光标在f"上,按 w 将光标移动到下划线.再次按下移动到b"栏.这是运动所需的效果,但具有破坏完成的不良副作用.与 CamelCase 令牌相同的故事.例如,
If cursor is on "f", pressing w moves cursor to the underscore. Pressing again moves to the "b" in bar. This is the desired effect for movement, but has the undesired side-effect of breaking completion. Same story with CamelCase tokens. For example,
如果我有这个:
foo_bar
然后我输入 foo_
我没有得到foo_bar"作为完成选项.
and I type foo_<CTRL+N>
I don't get "foo_bar" as a completion option.
推荐答案
安装 camelcase 运动插件 并按照页面上的示例使用 CamelCase 覆盖默认的 w
映射.这将使移动遵循 CamelCase,但不需要更改 iskeyword
.或者,您可以使用替代的逗号前置映射(我的偏好)、,w
、,e
等来执行 CamelCase 动作.
Install the camelcase motion plugin and follow the example on the page to override the default w
mapping with the CamelCase one. This will make movements follow CamelCase, but won't require changes to iskeyword
. Alternatively you can use the alternative comma-preceded mappings (my preference), ,w
, ,e
etc to do CamelCase motions.
这篇关于如何配置 vim 以便移动命令将包含下划线和 CamelCase,但完成将忽略它们?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!