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

13

7

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.

michael

Posted 2012-11-14T20:42:58.637

Reputation: 4 127

Answers

16

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

:syntax on

Ярослав Рахматуллин

Posted 2012-11-14T20:42:58.637

Reputation: 9 076

14

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.

Glenn Strycker

Posted 2012-11-14T20:42:58.637

Reputation: 240

I had to set cygwin type terminal (Options -> Terminal) to "xterm-256color" to get working – brrystrw – 2015-02-20T11:53:05.453

This breaks highlighting for me on VIM 8.0 See here

– Gert van den Berg – 2017-06-21T11:28:10.393

This should be the accepted answer, it worked perfectly for me. Thanks buddy. P.S. I recommend adding "hi Comment ctermfg=LightBlue" in the ~/.vimrc so comments are more visible – Iancovici – 2014-05-12T11:19:11.830

Thanks, echad, I was wondering how to get my comment lines more visible! – Glenn Strycker – 2014-05-12T19:47:48.453

5

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.

altendky

Posted 2012-11-14T20:42:58.637

Reputation: 244

2

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.

Mark

Posted 2012-11-14T20:42:58.637

Reputation: 235

1

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

404pio

Posted 2012-11-14T20:42:58.637

Reputation: 111

1You should add more detail to your question elaborating on why your solution works – Shekhar – 2013-11-13T18:31:18.100

No, cygwin terminal is configured fine by default. Either of them (console host or mintty). – Jan Hudec – 2014-05-01T20:04:39.450

0

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).

ThomasH

Posted 2012-11-14T20:42:58.637

Reputation: 153