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.
You can use WMI to get this information. The Win32_Process
class contains ParentProcessId
So (using PowerShell to execute WMI commands—other WMI tools are available):
gwmi Win32_Process -filter 'processid = 1234' | select ParentProcessId
will give the parent process id of process 1234.
Best Answer
When you select some text in the cmd.exe window, the process will carry on in the background until the next time it writes to Standard Output (or STDOUT, the data stream which is shown in the cmd.exe window).
When you exit the selection mode, the process will resume as normal.
You can test this by typing
ping www.google.com -t
into your cmd.exe window, and selecting some area of the output. You'll see it pause, and when you deselect the output will resume.Edit: As per Fran's comment, you can use a tool such as Wireshark to see that activity does still happen after the point when you made the selection, and then stops.