I want to make gvim be 'instance-only', i.e., know of an option or something that opens the file as a tab on my already-open gvim instance instead of opening a new one.
Allow me to just clarify something here ... in vim, tabs are not what people would expect them to be. In most programs they are an "instance" of a file (one tab/one file), but in vim they are merely a "viewpoint" into which you can have several vim windows, each one holding whatever you put in it.
Vim, when opening a file, opens it in a buffer. One buffer for every file. You can view the list of opened buffers with
:ls
Example to clarify: suppose I have a gvim window open with one file, module1.c. Supposing I'm on a terminal, what command do I have to enter in order to make 'module2.c' open in the same window that now has module1.c?
Again, we have a terminology problem. For the sake of discussion, I'll assume you mean "window" as in a windows window, and not a vim internal window.
If you wish to open a file in an already opened gvim instance try
gvim first_file.dat
gvim --remote-tab second_file.dat
This can easily be shortened by putting it in a .bat file (if you're on windows), and then you don't have to type the "--..." part over and over again.
PS: I'm aware that there's a -p option that allows me to open multiple files in multiple tabs. But what I'm looking for is a way to open a new tab from OUTSIDE gvim AFTER it is running already.
Interesting, I didn't know about that one :)
How to do it? Is it even possible?
Tell if that is what you were looking for.
excellent, thank you. I did alias=vim='/c/Program\ Files\ (x86)/Vim/vim73/gvim.exe --remote-tab' in cygwin – Jay R. Wren – 2011-04-29T19:57:17.353
You can do "Function g{ param($file) gvim --remote-silent $file }" in Powershell – zbstof – 2012-02-04T15:25:22.590
Yeah, that is exactly what I was looking for! =D Also, you can shorten the command with a shell script put on the /usr/bin folder (I called mine 'gvimt') – Rafael Almeida – 2009-12-25T03:42:30.997