Velvet Star Monitor

Standout celebrity highlights with iconic style.

updates

How to get vim color mode to work in vim under cygwin

Writer Andrew Mclaughlin

I have installed vim 7.3 under cygwin.

And I have this in my ~/.vimrc

$ cat .vimrc
colorscheme wombat

And then I have this file wombat.vim under '.vim/colors'.

 $ ls -la .vim/colors/
total 8.0K
drwxrwxr-x+ 1 cheungs mkgroup 0 Nov 12 00:04 ./
drwxrwxr-x+ 1 cheungs mkgroup 0 Nov 12 00:04 ../
-rw-r--r-- 1 cheungs mkgroup 1.5K Nov 12 00:04 wombat.vim

But when I 'vim AJavaFile.java', it shows no color, just black and white.

How can I fix it? I have the same settings under Ubuntu, and that works.

Thank you.

6 Answers

You have to (either run or) add the following command to your ~/.vimrc file:

:syntax on

I later found that I had installed both vi and vim on Cygwin, so I added this to my .bashrc:

alias vi="/usr/bin/vim"

and then created the following ~/.vimrc file:

" double-quotes are comments for the .vimrc file
set nocompatible
set nocp
set backspace=indent,eol,start
set term=xterm-256
syntax on
set hlsearch
set t_Co=8
set t_Sb=m
set t_Sf=m

I now have syntax highlighting, INSERT/REPLACE on the home bar, as well as correct arrow key operation and backspace/delete key operation during INSERT mode. Cygwin vi now behaves as my normal Linux vi.

4

As of vim-7.3.943 the vi binary is now compiled with the small featureset. To get syntax highlighting you must use vim (or alias vi to vim...).

This is likely a newer version than was available at the time of OP, but it is relevant now and is still v7.3 as listed in the OP.

For Cygwin by default, if you haven't installed vim you actually have vi. So just go onto Cygwin setup and search for vim and its under the Editors. Then colored syntax should all be enabled no changes required.

You should change cyngwin terminal options to xterm-256. Then restart termin

2

To put a little context to other answers:

The default install of Cygwin comes these days with a "small" Vim that has deliberatly only a few features turned on. Syntax highlighting is among those missing (so issuing ":syntax on" will yield nothing). This is available through the vi command.

But if you search the Cygwin setup, you also find a "full" Vim that is not installed by default. This has been compiled with many options turned on, among them syntax highlighting. Installing that will provide you with the vim command (which you may or may not alias to "vi", as of your liking).

As a quick way to find out which version you are currently running, enter :version. After the line with the version number, and before the multi-column list of possible options, the small version says

Small version ...

and the full version says

Huge version ...

If you are curious you can then look at the possible options, to find out which option in this build is actually available (+ prefix) or not (- prefix).

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy