[vox-tech] vim syntax highlighting
Peter Jay Salzman
vox-tech@lists.lugod.org
Fri, 30 Aug 2002 14:32:52 -0700
----- Forwarded message from Andy Wergedal <awerg@saclug.com> -----
Date: Wed, 28 Aug 2002 15:49:22 -0700
From: Andy Wergedal <awerg@saclug.com>
To: p@dirac.org
Subject: vim syntax highlighting
Pete,
I would like to make a very simple syntax file for vim so I could use it
for my personal journal.
All I want to do is highlight the individual line in a color based on
the first character of the line.
black background
* red
- Blue
-- green
spaces or alpha characters would be the default font color.
Where should I go to get this information?
-- Andy
----- End forwarded message -----
hi andy,
i'm forwarding this to vox-tech. i wrote "andy.vim" just now. here it
is:
" ==================================== CUT HERE ========
" andy.vim
"
" see mike's reply to my vim question on august 30 for info
" about where to put it. you can also put it in "." and
" simply type "source andy.vim".
"
" see "help highlight" for more information about colors.
" ========================================================
""" This is the real way of doing things:
" if version < 600
" syntax clear
" elseif exists("b:current_syntax")
" finish
" endif
""" But let's keep things simple for now.
syntax clear
""" Case insensitive
" syntax case ignore
""" Case sensitive
syntax case match
" Define color names
"
highlight Black ctermfg=0 guifg=black
" highlight Black ctermfg=black guifg=black
highlight Red ctermfg=1 guifg=red
" highlight Red ctermfg=red guifg=red
highlight Green ctermfg=2 guifg=green
" highlight Green ctermfg=green guifg=green
highlight Yellow ctermfg=3 guifg=yellow
" highlight Yellow ctermfg=yellow guifg=yellow
highlight Blue ctermfg=4 guifg=blue
" highlight Blue ctermfg=blue guifg=blue
highlight Magenta ctermfg=5 guifg=magenta
" highlight Magenta ctermfg=magenta guifg=magenta
highlight Cyan ctermfg=6 guifg=cyan
" highlight Cyan ctermfg=cyan guifg=cyan
highlight White ctermfg=7 guifg=white
" highlight White ctermfg=white guifg=white
" Define words (aRed) to match syntax within document (/^r .*$/).
"
syntax match aRed /^r .*$/
syntax match aBlue /^b .*$/
syntax match aGreen /^g .*$/
syntax match aYellow /^y .*$/
" Now define colors for the words.
"
highlight link aRed Red
highlight link aBlue Blue
highlight link aGreen green
highlight link aYellow yellow
" ==================================== CUT HERE ========
here is an example file you can use this for:
r I shot an arrow into the air,
b If fell to earth, i knew not where;
y For, so swiftly it few, the site
g Could not follow it in its flight.
after typing :source andy.vim, the lines will be red, blue, yellow and
green respectively.
you'll definitely want to tweak this for other things too. you can have
"bold" or "standout" and "dark/light" choices. the vim book by steve
oullaine(sp?) and :help highlight are good resources.
pete
--
Fingerprint: B9F1 6CF3 47C4 7CD8 D33E 70A9 A3B9 1945 67EA 951D