Vim 的“超级明星”操作(搜索并突出显示光标下的单词)非常方便。但它在搜索精确匹配上有局限性whole word.
是否有可能具有类似的功能,但没有封闭的字边界括号?
更新:显然我太快提出问题了。看着here http://vim.wikia.com/wiki/VimTip1,这就是答案。
using g * is probably the best solution, but for new vim users it might be interesting to know how this could be done pretty much from scratch:
:nnoremap <expr> * "/".expand("<cword>")."/\<CR>"
map <expr>
意味着右侧不是映射到文字键序列,而是每次映射发生时都会评估的表达式,并且将结果字符串视为普通映射的 RHS。
expand("<cword>")
返回包含光标下单词的字符串,并且"\<CR>"
基本上只是意味着回车键。
So in the end we get a mapping to /<word under cursor>/
enter, where the word under cursor isn't inserted until the mapping is used.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)