0

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?

xihh
  • 169
  • 2
  • 12

1 Answers1

0
  1. 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.

  2. 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".

  3. To add external tool output into cursor position use, for example,

put=system('blah blah')

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.

Matt
  • 13,674
  • 1
  • 18
  • 27