Tuesday, March 17, 2009

Vim + Cygwin Improvements

I've been stuck in a Windows environment at work for the last month or so doing Blackberry development. To try and make things more tolerable, I've been doing most of my work in a Cygwin environment; however, the Cygwin Vim build is sub-optimal compared to the native Windows build. This lead me to try and find a way to use Windows Vim seamlessly from inside Cygwin. The following alias worked out nicely:

[bash-fu borrowed from this tip]

alias vim='VIM=`cygpath -d "$VIM"` HOME=`cygpath -d "$HOME"` "`cygpath -u "$VIM"`/vim72/vim.exe"'

In this case, the $VIM environment variable is initially set to C:\Program Files\Vim. It's also important to change the vim72 version number to whatever matches your install.

The second thing I did, which is making life a lot easier, is switch to using Console2 as a replacement for the standard Windows cmd.exe. The combo of Console2, Cygwin, and a decent Vim build is a good bet if you're committed to Windows for whatever reason.


Anonymous said...

Hi Travis,
I have cygwin installed on Windows, but I simply use the commands (ls, grep, wc, etc.) without using the cygwin environment. Seems to work better that way. Once you've added c:\cygwin\bin\ to your path, there seems to be little advantage of using the cygwin shell environment. (And Windows has a few nice things available on the command prompt, such as tab-completion and the command history that appears when you press F7).


hT_SdJQI0euJYoaKCWzdQNBUL_c4O2yenqNoY60M3Q-- said...

Where is the .bashrc equivalent in cygwin (i.e. where do you put the alias :) )

Slestak said...

I have seen in the past a build of putty with patches for cygwin as well. A nice alternative to cmd.exe

Greg said...

You can put your alias in ~/.bash_profile.

I use cygwin via sshd and PuTTY, as described here (bottom of article). PuTTY is a superior interface to bash compared to the Cygwin window or Windows cmd.exe, with the main benefit for me being that highlighting text copies it to the Windows clipboard. I haven't really run into any problems with vim under Cygwin (not as intense a user as you, perhaps). Out of curiosity, what are some differences?

Avi said...

Why not install also cygwin-x and work with Xterm?

Armentage said...

The main reasons not to use Xterms are
1) the free cygwin xserver is pretty slow
2) Most Xservers do a horrible job rendering fonts; they simply do not compare to native Windows (or Mac) font rendering. If you care about such things, any of the native Win32 shells are a much better choice.

RK said...

There is Xterm and RXVT versions in Cygwin which do not require X server, I am sticking to RXVT which is very nice:)