3 回答
我建议使用这个 PERL Regex 插件,因为它已经完成了你想要的。
Abbreviations ...
I understand you often use the same regex. You can use abreviations instead of a command to do a search.
ab re -\s*(
then type / + re + space and your long regex (here just "-\s*(" should expand).
... Not user defined command
User defined commands are not available in ed nor in vi nor in vim without the +eval compilation flag (:h user-commands
and scroll one line up).
For a list of ex commands: http://www.csb.yale.edu/userguides/wordprocess/vi-summary.html
For a list of ed commands: http://pubs.opengroup.org/onlinepubs/7908799/xcu/ed.html
您的命令甚至无法在原始 Vim 中运行。我不知道 xVim,但可以尝试以下方法:
" With cursor moving to match.
command Foo /foo/
" Just updating the search pattern (but less likely to be portable to xVim).
command Foo let @/ = 'foo'
如果这些都不起作用;尝试定义映射。由于这只是翻译键,因此它最有可能被支持。