Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I need to connect to a remote server by SSH to edit some documents. When I work at home, I SSH to the remote server using SSH Secure Shell and open emacs, but it doesn't fully highlight documents as I want:

Screenshot of emacs on this server

Is there any way to fix it so that syntax highlighting works like when I ssh through Cygwin?

Screenshot of emacs on Cygwin

SSH Secure Shell only has a problem with emacs; everything else works fine.

Syntax highlight works for bash

share|improve this question
When you ssh to a server and start up emacs, it will source the configuration file ~/.emacs on the server. If you don't have one there, it may be the problem. Just copy it from your local machine. – user13742 Jan 11 '12 at 10:36
What is the value for $TERM in both? – symcbean Jan 11 '12 at 12:19
@symcbean On my SSH client, the $TERM has the value of vt220. When I change its value by executing export TERM=ansi, emacs fully highlights documents. Thank you! – Federico Magallanez Jan 11 '12 at 15:13
What terminal emulator are you using? On Windows, I recommend using PuTTY. – Gilles Jan 12 '12 at 1:11
You should post changing your TERM as an answer and accept it. – Kevin Feb 21 '12 at 20:54

Adding to Gilles' line of thought, I'd suggest using Cygwin's MinTTY terminal instead of the Windows console-based one. It uses PuTTY's engine and offers a much, much better experience.

share|improve this answer

see if M-x font-lock-mode fixes this for you. if it does, but (global-font-lock-mode 1) into your .emacs file

share|improve this answer

Suggestion from symcbean comment solved the problem, but there is one interesting possibility.

Why open Emacs in ssh if you can open ssh in Emacs? ;) If you have TrampMode which is part of standard Emacs installation you can press Ctrl+x f and enter /ssh:hostname:filename (you can use Tab completion) and press Enter. After that you will be prompted for password to remote host and file will be opened.

This should work for your problem as Emacs is opened on local machine. Next advantage is that there is no need to have configs for Emacs (end even Emacs) on remote machine.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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