Monday, March 1, 2010

Re: one instance of gvim on windows?

On Mon, 2010-03-01 at 17:46 -0800, Bee wrote:
>
> On Windows, is it possible to prevent new instances of gvim and have
> the document open in the current gvim by double clicking?

It is, the Cream configuration has this feature. Basically, you use
gVim's server variable. By default, gVim's first instance will use a
consistent servername, "GVIM". Successive instances will use a
different name, starting with "GVIM1".

Via autocmd on start, each instance can check to see if it is "GVIM".
If it is, nothing has to happen. But if it isn't, that session passes
a command to the first instance with the pathfilename of the file it
had opened so the first instance can open it. Then the second instance
closes itself.

function! MyServer()
if v:servername !=? "GVIM"
let mycmd = ":edit " . fnamemodify(expand("%"), ":p") . "<CR>"
call remote_send('GVIM', mycmd)
q!
endif
endfunction
autocmd VimEnter * call MyServer()

This is more or less pseudocode, you will have to do some work
ensuring that the pathfilename is correctly discovered prior to
sending it to the second instance.

(Cream has a lot of overhead ensuring the correct pathfile and format
are discovered, forwarded, and handled at the other end due to
complexities with odd filename character possibilities over multiple
platforms. If you're the type of person who stays on *nix and doesn't
use spaces in filenames, you might not see a single issue.)

--
Steve Hall [ digitect dancingpaper com ]


--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

No comments: