I'm playing a game that has a scripting language. It has a button to open the scripts in external editor. You can set the command that will trigger the editor from within the game's interface.
/usr/bin/X11/gvim
opens the scripts in gvim
now what I would like to know is, if it's doable, to open the scripts in terminal's vim and if instead of opening a new one each time to add tabs to the existing instance. What would be a command to do that?
the way of adding tabs is :tabe filename
or from terminal for multiple documents
vim -p file1, file2
I guess there are more that I don't know, I hope this is doable.
Thanks.
答案1
Yes, this is possible with vim's server mode. Start a vim-server with:
vim --servername somename
Now you can send commands to it with --remote
, --remote-send
and others.
To achieve what you want, start a server with a known name, send the :tabe
commands with:
vim --servername somename --remote-send ':tabe filename<cr>'
Note the same commands work for gvim. If this should work from within another program, you need to start the vim-server prior to any --remote-send
commands. The edit command within the program should then be: vim --servername somename --remote-send ':tabe %s<cr>'
, assuming %s
is replaced by the filename to edit.