Since my google-fu is failing me, can anyone give me a simple example on how to use --remote-expr
or any other command line trick to insert text to current buffer, or to set a cfile. (Any : -command would be good.)
All I manage to get with --remote-expr
is E449: Invalid expression received
for anything.
:help E449
leads you to a basic example. Unfortunately it is a bit too basic:
remote_expr({server}, {string} [, {idvar}])
Examples:
:echo remote_expr("gvim", "2+2") :echo remote_expr("gvim1", "b:current_syntax")
In command line, that turns into
$ vim --servername "gvim" --remote-expr "2+2"
4
To get an idea what you can do with expressions, see :help expr
.
You are better off with --remote-send
that sends key sequences in similar manner as you'd do with map
s or abbr
s:
$ vim --servername Foo --remote-send "GoHello world! <ESC>"
will append a new line at the end of the active window's buffer.
If you want to execute a command, let's say :ls
, to get a list of buffers, you can do
vim --servername GVIM --remote-expr "execute(\"ls\")"
This will print the list of all buffers in GVIM server. Note the escaped quotes.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With