开发者

What is difference between "function" and "function!" in VIM?

开发者 https://www.devze.com 2022-12-12 22:40 出处:网络
I beheld quite a few usage of \"functi开发者_开发百科on!\" in others vimrc files, but there is no easy-to-find documentation of \"function!\".

I beheld quite a few usage of "functi开发者_开发百科on!" in others vimrc files, but there is no easy-to-find documentation of "function!".

What's the difference between "function" and "function!"?


:help user-functions

When a function by this name already exists and [!] is
not used an error message is given. When [!] is used,
an existing function is silently replaced. Unless it
is currently being executed, that is an error.


In general, it suppresses the messages the command may spit out.

For instance, using function!, you can redeclare an already defined function.


function (with appropriate) parameters defines a new function but fails if a function already exists with the given name. function! will always replace any existing function of the given name with the new definition supplied.

This says as much:

:help function
0

精彩评论

暂无评论...
验证码 换一张
取 消