6

据我了解,w通过将文本分成 3 组来识别单词边界:

1) 设置中指定的字符iskeyword(字母、数字和下划线)

2)其他不可打印的字符(符号)

3) 空白字符

每次按下w它都会转到下一个组 1 或组 2。我想对其进行自定义,使其仅转到下一个组 1,跳过“符号词”。

几乎可行的是:

nnoremap w /\k\+<CR>

它使用iskeyword字符类\k。但它很丑,因为它模拟了我执行搜索,这改变了我的突出显示,混乱了我的搜索历史,谁知道还有什么。有没有办法让这项工作像w通常的命令一样“干净”?

4

2 回答 2

3

我认为您正在寻找运营商待定模式,又名xmap, smap和家庭。

我在 SO 的其他答案中做了一些例子:

最相关的例子可能是

您还会发现一些类似的并且可能对您有用的技术

于 2012-03-02T22:07:41.333 回答
0

I may not be much help here .. I don't even know what \k means in this context, but you can solve the two immediate problems you present:

nnoremap w /\k\+<CR>:nohl<CR>:call histdel("search", -1)<CR>

It's ugly and the highlighting may flicker, but maybe this will point you in the right direction.

于 2012-03-02T22:00:06.343 回答