http://www.vim.org). It’s got all the features of vi and more. One powerful feature is called syntax highlighting; it helps immensely when programming because it provides additional visual clues when editing source code.

" />
x
Loading
 Loading
Hello, Guest | Login | Register

Combining Vim’s Syntax Definitions

If you fall on the vi side of the “Great Editor Debate,” then hopefully you’re using vim (http://www.vim.org). It’s got all the features of vi and more. One powerful feature is called syntax highlighting; it helps immensely when programming because it provides additional visual clues when editing source code.

If you fall on the vi side of the “Great Editor Debate,” then hopefully you’re using vim (http://www.vim.org). It’s got all the features of vi and more. One powerful feature is called syntax highlighting; it helps immensely when programming because it provides additional visual clues when editing source code.

However, if you turn on syntax highlighting (by using syntax on in your local .vimrc file) and then attempt to view code that contains a mix of Scheme and Perl (as outlined in last month’s column), you’ll probably see something like what is shown in Figure One.

Bad Highlight
Figure One: Viewing a mix of Scheme and Perl in vim.

Because vim doesn’t know that everything within a pair of curly braces is Perl code, it highlights that section in red as if there were a syntax error. Vim can highlight either Scheme or Perl on an individual basis, but it can’t do both of them simultaneously. Not yet, anyway.

The Structure and Interpretation of Syntax Highlighting Files

Vim uses syntax highlighting files to control how the text from the file being edited should be displayed. The file name or suffix generally determines which highlighting file to use.

These syntax-highlighting files are usually composed of two major sections. In the first, syntax…

Please log in to view this content.

Not Yet a Member?

Register with LinuxMagazine.com and get free access to the entire archive, including:

  • Hands-on Content
  • White Papers
  • Community Features
  • And more.
Already a Member?
Log in!
Username

Password

Remember me

Forgotten your password?
Forgotten your username?
Read More
  1. Claws Mail: Mail with Attitude
  2. IE8 vs. Firefox: Four Things Firefox Could Learn from IE
  3. Vimperator: Use Firefox the Vim Way
  4. Customize Chrome for Better Browsing
  5. Jetpack Gearing Up for Production: Look Out Chrome?
Follow Linux Magazine
Rackspace