In vim, how do I define a function that can be called without :call?

荒凉一梦 提交于 2020-08-18 09:06:08

问题


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


回答1:


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()


来源:https://stackoverflow.com/questions/7434142/in-vim-how-do-i-define-a-function-that-can-be-called-without-call

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!