How to send commands to gvim when using --remote?

前端 未结 2 1878
伪装坚强ぢ
伪装坚强ぢ 2020-12-20 15:39

I want to look at the output of a command in a GVim window that\'s already opened.

To look at the output of a command in a new GVim window, I\'d do:

         


        
相关标签:
2条回答
  • 2020-12-20 16:10

    Try gvim --remote-silent <(mycommand).

    0 讨论(0)
  • 2020-12-20 16:15

    Assume you have Gvim running with default servername GVIM, here's a command to execute :echo 'It works!' in the running Gvim:

    vim --servername GVIM --remote-send ":echo 'It works!'<CR>"
    

    This command returns nothing, it just sends ":echo 'It works!'<CR>" to the server and returns immediately.

    If you need to evalute an expression and get the result, you might use this command:

    vim --servername GVIM --remote-expr "version"
    

    (version number will be returned)

    vim --servername GVIM --remote-expr "2+2"
    

    ("4" will be returned)

    Of course, you can declare your own function in Vim and use it as a expression, just like that:

    vim --servername GVIM --remote-expr "MyOwnFunction()"
    
    0 讨论(0)
提交回复
热议问题