Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I would like to set up an alias in my cygwin .bashrc that translates pathnames unix-to-dos and passes them to windows gvim in a new tab of an existing instance. I am trying to use Luc Hermitte's cyg-wrapper script for running native win32 applications from Cygwin as per this vim tip. Luc's example of how to use his script is:

alias vi= ' "C:/Progra~1/Edition/vim/vim63/gvim.exe"

I do not understand this example because most of these vim parameters (-c,--cmd,--servername,--remote-send,--remote-expr, etc) require more information, and I have not found any example of how to supply the additional information to For example, calling

C:/Progra~1/Edition/vim/vim63/gvim.exe --servername=GVIM 
   --remote-tab-silent file1 &

will open file1 in a new tab of existing (or non existing) instance GVIM, but calling gvim --servername accomplishes nothing on its own. Unfortunately, though, the corresponding cyg-wrapper phrase does not work: "C:/Progra~1/Edition/vim/vim63/gvim.exe"
    --binary-opt=--servername=GVIM,--remote-tab-silent --fork=2 file1

If ran twice, this actually opens up two instances of gvim; it is as if the servername 'GVIM' is being stripped and ignored. How do you supply a servername to gvim --servername or a .vimrc to gvim -u using

Furthermore, why is it that programs must be passed to in the relatively obscure "mixed form?" For example, if I try "/cygdrive/c/path/to/GVimPortable.exe"
        --binary-opt=--servername=GVIM,--remote-tab-silent --fork=2

I get "Invalid switch - "/cygdrive"."

See also:

share|improve this question
up vote 1 down vote accepted

The key is to not put the key-value pair options in --binary-opt. The correct way here is: "C:/Progra~1/Edition/vim/vim63/gvim.exe" --fork=2 
  --servername=GVIM --remote-tab-silent .bashrc.

It is a little bit more complicated when passing in a vimrc. I did not know this, but when passing in a vimrc, the -u parameter must come earlier than other parameters; this: "C:/Progra~1/Edition/vim/vim63/gvim.exe" --fork=2 
      --servername=GVIM --remote-tab-silent -u ~/.vimrc file1

will actually open up three tabs, one called "-u", one that opens ".vimrc", and one with "file1." To get Cygwin and gvim to open up file1 in a new tab after sourcing a specified .vimrc, you need: "C:/Progra~1/Edition/vim/vim63/gvim.exe" --fork=2 
      -u ~/.vimrc --servername=GVIM --remote-tab-silent file1

The order of the parameters appears to be important. I may be wrong; I just figured this out experimentally and it isn't mentioned in the GVim documentation, but I think that first come the parameters for such as --fork=2, then the single letter parameters for vim such as -u , then the other vim parameters with double hyphens, and finally, the list of files to open.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .