Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run windows gvim from cygwin?

Tags:

vim

cygwin

I am not able to run gvim from cygwin. When I try to open a new file with :

gvim filename gvim opens a file with 'No name' and displays error as :

Error detected while processing command line
E492: Not editor command: C:\cygwin\home\chandan\l
Press enter or type command to continue 

More problematic is that I can't open existing file in the path

>which gvim shows /usr/bin/gvim

I have put alias gvim=/cygdrive/c/Program\Files\(x86\)/Vim/vim73/gvim.exe still

like image 505
Chandan Choudhury Avatar asked Sep 29 '12 15:09

Chandan Choudhury


People also ask

What gVim Windows?

Vim is a text editor that is based on the Vi editor, which is common to UNIX-like systems. gVim is the GUI version of Vim. This article is a detailed account on how to install gVim on a Windows 7 machine along with Git, Pathogen and plugins.


1 Answers

I wrote cyg-wrapper.sh for this sole purpose.

It supports:

  • symbolic links
  • options that must not be interpreted as pathnames (see -c with gvim, or any flags starting with a minus sign).

In other words, it enables us to type:

  gvim /etc/profile -c /PS1 -c "echo 'correctly opened'"
# or even:
  cd ~/tmp ; ln -s ~/bin/cyg-wrapper.sh 
  gvim -d http://hermitte.free.fr/cygwin/cyg-wrapper.sh cyg-wrapper.sh

  explorer -e
  explorer "$vim"
  explorer http://hermitte.free.fr/

Note: I use the following function in my .profile to run gvim with cyg-wrapper.sh

gvim() {
    opt=''
    if [ `expr "$*" : '.*tex\>'` -gt 0 ] ; then
    opt='--servername LATEX '
    fi
    cyg-wrapper.sh "C:/Progra~1/Edition/vim/vim73/gvim.exe" --binary-opt=-c,--cmd,-T,-t,--servername,--remote-send,--remote-expr --cyg-verbose --fork=2 $opt "$@"
}

EDIT: Currently (Sept 26 2014, using Vim 7.4), Windows gVim uses C:\Windows\gvim.bat to launch gVim from the command line. Replacing the gvim.exe path in the gvim() function with this script allows launching gvim without changing the path to match the current Vim version (which may actually be in Progra~2); however, it appears to also open a superfluous cmd.exe window.

like image 198
Luc Hermitte Avatar answered Oct 14 '22 18:10

Luc Hermitte