Vim Syntax-Highlighting Works In a Shell (I Didn’t Know That!)

I’ve been using the great Vim editor for many years (and vi even longer), but I just learned something about it this morning. Usually when I use Vim, I’m using gvim, which means it opens in its own GUI window. I had a stanza inside my .vimrc that would set some things only if Vim was running in GUI mode, and one of those things was syntax-highlighting. The bummer was that whenever I’d have to use Vim inside a shell (typically via ssh) I didn’t get the pretty pretty colors.

This morning I was looking at the FAQ for iTerm and noticed a screenshot section. I clicked on it, and one of the shots was of Vim, running inside iTerm, with full syntax-highlighting. I was surprised. I had never even tried to enable syntax-highlighting inside a shell. For some reason it never occurred to me that it would work, or even to try it. So I Cmd-Tabbed over to a shell, opened Vim on an XML file and typed :syntax on and BLAMMO! full-color XML. Very nice! I then edited my .vimrc to move the syntax on directive out of the GUI-only section and into the common area on all the machines I work on. It works perfectly. I can’t believe I’ve lived so many years without this feature turned on, but I’m quite happy now.

Share and Enjoy:

  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • email
  • FriendFeed
  • Identi.ca
  • MySpace
  • Ping.fm
  • Posterous
  • Reddit
  • Slashdot
  • StumbleUpon
  • Technorati
  • Tumblr
  • Twitter

Comments are closed.

Follow Me
Previous Posts
March 2007
S M T W T F S
« Feb   Apr »
 123
45678910
11121314151617
18192021222324
25262728293031
Archives
Categories
Google Reader Shared Items