在vim中,如何定义无需:call即可调用的函数? [英] In vim, how do I define a function that can be called without :call?
本文介绍了在vim中,如何定义无需:call即可调用的函数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何定义一个函数,以便我可以从命令行模式调用它而无需在其前面调用:
现在,我必须这样做::call TrimWhitespace()
我想定义它以便执行此操作::TrimWhitespace
解决方案
这不是函数,您应该创建命令.查看命令(在Vim中为:help user-commands
)的文档.>
最简单的情况是使用命令调用函数:
command! TrimWhitespace call TrimWhitespace()
How do I define a function so that I can call it from command-line mode without :call in front of it?
Right now, I have to do this: :call TrimWhitespace()
I want to define it so that I can do this: :TrimWhitespace
解决方案
This won't be a function, you should create a command instead. Check the documentation for commands (:help user-commands
in Vim).
The simplest case is of a command to call a function:
command! TrimWhitespace call TrimWhitespace()
这篇关于在vim中,如何定义无需:call即可调用的函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文