有没有办法将命令添加到Neovim中,可以称为“:命令”?
我想归档的是能够使用:< shell命令
,然后将输出添加到shell命令到光标在Neovim的位置。
看来我可以使用:redir来拱起此功能并将其包装到功能中。
有没有办法将[neo] vim函数与:命令
相关联?
What I would like to archieve is to be able to use :< shell command
and add the output to the shell command to the cursor's position in neovim.
It seems I could use :redir to archieve this functionality and wrap it in to a function.
Is there a way to associate a [neo]vim function to :command
?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
命令无法返回值。因此,命令不是表达式。特别是,命令永远不会被“嵌套”到另一个,例如函数调用。参见例如,外壳脚本。
原则上,有一些技巧,例如一个接受命令名称,运行它并返回输出为字符串值的内置函数。但这是“方便的redir”,而不是“语法断路器”。
将外部工具输出添加到光标位置使用中,例如
这是合法的,因为(某些)命令可以接受表达式,包括函数调用。
不过,请确保逃脱“ bar”和“双引号”,因为(有时)它们在vimscript中很特别。
A command can't return value. Hence a command is not an expression. And in particular, commands never can be "nested" one into another, like function calls. Cf. Shell scripting, for example.
In principle, there are some tricks, like a builtin function that accepts command name, runs it, and returns output as string value. But this is rather "convenient redir", not "syntax breaker".
To add external tool output into cursor position use, for example,
This is legal, as (some of) commands may accept expressions, including function calls.
Make sure to escape "bars" and "double quotes" though, as (sometimes) they are special in VimScript.