13

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.

16

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

:syntax on

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.

  • 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 May 12 '14 at 11:19
  • Thanks, echad, I was wondering how to get my comment lines more visible! – Glenn Strycker May 12 '14 at 19:47
  • I had to set cygwin type terminal (Options -> Terminal) to "xterm-256color" to get working – brrystrw Feb 20 '15 at 11:53
  • This breaks highlighting for me on VIM 8.0 See here – Gert van den Berg Jun 21 '17 at 11:28
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.

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.

1

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

  • 1
    You should add more detail to your question elaborating on why your solution works – Shekhar Nov 13 '13 at 18:31
  • No, cygwin terminal is configured fine by default. Either of them (console host or mintty). – Jan Hudec May 1 '14 at 20:04
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).

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.