I use cygwin on Windows7 to open a ssh session to my linux box. When I edit a file with vim, I don't have color, only kind of gray bold.

I have colors when I do a ls into my ssh session.

I have also colors when I edit files from a ssh session from my linux box to my linux box.

I modified the shortcut on Window7 to run cygwin in 256 colors, no effect.

Do I need to set an environment variable on my cygwin session ?


On Cygwin and On Fedora when "sshed" from Gygwin : TERM=cygwin

  • Maybe. What does echo $TERM report on the Windows machine and on the Linux machine? What terminal do you run ssh in (a Windows console, rxvt, ...)? – Gilles Nov 25 '10 at 1:49
  • Are you invoking Vim as "vi" or "vim" on the command line? Many distributions have a stripped down version of Vim installed as "vi" that does not support highlighting, plus a complete version installed as "vim". – Heptite Nov 25 '10 at 2:10
  • @Heptite I use vim my_file – Luc M Nov 25 '10 at 3:22
  • @Gilles Both xterm are set to cygwin by default. I use ssh into a shortcut of cygwin. It's pointed to a bat file that executes bash --login -i. – Luc M Nov 25 '10 at 5:20

Maybe the Linux box doesn't have the right data about the cygwin terminal type. You could try using a different terminal on the Windows side: instead of starting cygwin.bat, start c:\path\to\cygwin\bin\rxvt.exe -e c:\path\to\cygwin\bin\bash --login (Cygwin ships with a Windows native version of rxvt). There are alternatives to rxvt (which, in particular, is not Unicode-aware), such as mintty and puttycyg. These alternatives tend to be better for running Cygwin programs in; for Windows console programs, Console2 works better (Cygwin doesn't emulate a Windows console). See also Good Alternative to Cygwin with Copy/Paste?.

  • That's definitely worth a try, although both Fedora 14 and Ubuntu 10.04 include cygwin in their terminfo databases, so Luc's Fedora box should recognize cygwin as a terminal type. – garyjohn Nov 25 '10 at 16:25
  • @garyjohn: you're right, and if cygwin was not recognized the symptoms would be much worse. I still recommend mintty or puttycyg for cygwin programs anyway. – Gilles Nov 25 '10 at 20:35
  • It works! I'll give a try to mintty and puttycyg to get unicode support. Thank you. – Luc M Nov 26 '10 at 0:57

Try setting syntax on in vim:

:set syntax on

look here:

Check some other file type - e.g. edit a new file "abc.c" and put the C program from the above link. If you don't get syntax coloring, you are probably using some old vim.

If you don't have vim-enhanced installed, install that one, though I have that installed on Fedora 13.

  • I use the vim version available in yum depot for fedora13. I have syntax color in session from my fedora box. When I set TERM to vt102, the arrows key don't work in vim to recall previous command. – Luc M Nov 25 '10 at 2:54
  • I try setting TERM on cygwin and on Fedora. Niet :-( – Luc M Nov 25 '10 at 3:00
  • Take a look here: forums.fedoraforum.org/showthread.php?t=217019. It suggests installing vim-enhanced, so if you only have vim-minimal, try that. – icyrock.com Nov 25 '10 at 3:12
  • 1
    You don't need to set TERM on the Cygwin box; you may need to set it on the Linux box. Don't set TERM to vt102, however, as that will tell Vim that your terminal doesn't support colors. I just tried connecting to my Linux box from my Cygwin box using both the default Cygwin terminal (which sets TERM=cygwin) and mintty (which sets TERM=xterm) and I get color in Vim just fine, so we should be able to get it to work for you. Please answer Gilles's question above. – garyjohn Nov 25 '10 at 3:25
  • 1
    What I do in situations like this is to compare the two environments, compare the two Vim configurations, and examine the differences. When logged in to Linux directly: 1) execute env > env.linux; 2) execute vim --version > version.linux; and 3) execute vim -c 'mkv vimrc.linux' -c q. Do the same when ssh'd from Cygwin, but change "linux" to "cygwin" in the file names. Then run vimdiff on each pair of files to look at the differences. You may need to edit the files to get the variables to line up. – garyjohn Nov 25 '10 at 4:16

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.