Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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.

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

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.

share|improve this answer
    
Ty for your answer, I def learned something from that. But it doesn't seem to work. The problem is that I don't actually know how that external editor command works. E.g why wouldn't open vim in terminal? Even a single instance, it just wont do it. But it will open gvim. This is not kewl. Plus I don't know if it can accept command line arguments. This really bothers me, multiple windows are never good. –  Deus Deceit Dec 4 '12 at 20:23
    
@DeusDeceit: IIUYC, you should first start the vim-server outside the program that will call vim --remote-send. See the added note above. –  Thor Dec 5 '12 at 8:38
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.