Using Vim under Cygwin
Cygwin is a marvelous idea: run a Linux-like shell under Windows. It allows me to run Python, CVS, Perl… almost everything I use under Linux, under Windows. Well, it doesn’t quite work as well, but for small things, it does the job.
One thing that has annoyed me is their implementation of vim. The keyboard support is bad. In my .inputrc, I have these lines
# enable 8-bits characters ... set meta-flag on set convert-meta off set output-meta on
They seem to clash with vim in a bad way. Ah! But you can also install a version of vim running directly on top of windows. If you do this, then you can use this other version instead of the one that comes with cygwin.
All I had to do was to create this little script:
"/cygdrive/c/Program Files/Vim/vim63/vim.exe" `cygpath -w $1`
The trick here is that you need to convert Linux-like paths (like /tmp) into Windows path (C:…). My little script is bad in many ways, but it will work if you call vim with only a file name as an argument.
My solution does fail in some nasty ways. For example, when I do a CVS commit, I can’t enter my comment. Bad.
See also my post Grep is just not for matching lines anymore.
Subscribe to this blog ![]()
in a reader
or by Email.
You can use the -m ‘log_message’ option for the commit to enter the comments.
Comment by Zbigniew Lukasiak — 18/2/2005 @ 4:53
-m message
Use message as log information, instead of invoking an editor.
Available with the following commands: add, commit and import.
From cvs man page.
Comment by Zbigniew Lukasiak — 18/2/2005 @ 5:00
Thanks. Indeed a good alternative.
I knew about the “-m” command, but also, under windows, one can use Tortoise CVS, you then have a nice GUI to take care of all your CVS trouble. But I remain a command line freak. So I should get in the habit of using -m, it is probably faster in the long run anyhow.
Comment by Daniel Lemire — 18/2/2005 @ 14:01
cat ~/.bashrc
vi(){ # windows.
vifile=${@:-$vifile}; # use last file or argv
vifile=$(cygpath -m $@) # dos paths
c:/bin32/gvim $vifile &
}
I too just started using cygwin and tortoise-cvs.
Comment by Dr.M — 16/4/2005 @ 0:52
Hello.
I do not really like to post such plain advertizes, but I think the script I’m maintening, cyg-wrapper.sh, could solve both your problems. (If I understand how the blog works, just click on my name to access to the script).
Regarding Vim, look at the example given on the web page. Regarding cvs, declare -m as a binary-argument. BTW, Vim plugin, cvsmenu, is quite addictive — though I have used it only on Solaris.
NB: As cyg-wrapper is just a bash script, it may take some time when to many filenames need to be converted.
HTH.
Comment by Luc Hermitte — 29/9/2005 @ 19:00
The script as given above will only edit one file. What if you want to edit several files? What if you want to edit several files and start all open in their own frame? If you add the “-o” switch cypath will take it as a option so it probably produce an error and it won’t get passed to Vim.
Here’s the original script:
“/cygdrive/c/Program Files/Vim/vim63/vim.exe” `cygpath -w $1`
Here’s a more useful variation (assuming the Bash shell):
“/cygdrive…/vim.exe” $(cygpath -w — $*) &
Cygpath ignores options after the “–”.
Comment by TidyTim — 18/7/2007 @ 10:55