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

  • 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
  • 4
    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

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.


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


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.

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.