" Kind: Setup file for the editor "Vim" - "syntax file" " Language: Text - Colors for normal text editing " Maintainer: Sven Guckes " Last change: Wed Mar 24 06:30:00 MET 1999 " URL: " General remark: This file is a "Vim syntax file". " It contains definitions for text and sets the rules to colorize them. " The rules within this file give color to the following kinds of text: " Whitespace (sequences of space and/or tabs) at the end of lines, " whitespace at the end of lines, tab runs within the text, " high-bit characters (so I'll remember to convert them before I post on " Usenet thus avoiding base64 conversion). email addresses and URLs. " However, not everything is working as I had expected. " If you have a better solution then please let me know! " -- Sven guckes@vim.org " ========================================================================== " Syntax Clear: Removes existing definitions/rules. syn clear " Set the keyword characters " set isk=@,48-57,_,- " Define names for colored text: " source ~guckes/.P/vim/syntax/colnames.vim " todo: Make color setting depend on the current background, ie " dark, light, or greyscale. " Spaces: Spaces in WhiteSpace - both at *start* and *end* of lines. syn match Spaces contained " " hi Spaces term=reverse ctermfg=Black ctermbg=DarkBlue " Tabs: Tabs anywhere in the text. syn match Tabs "\t\+" hi Tabs term=reverse ctermfg=Black ctermbg=DarkGreen " Escape " IndentWhitespace: WhiteSpace at *start* of lines. " syn match IndentWhitespace "^\s\+" contains=Spaces " syn match IndentWhitespace "^\s\+" " hi IndentWhitespace term=reverse ctermfg=Black ctermbg=DarkRed " TrailWhitespace: WhiteSpace at end of lines syn match TrailWhitespace "\s\+$" contains=Spaces hi TrailWhitespace term=reverse ctermfg=Black ctermbg=DarkRed " Attribution: String that reference the person you are quoting: " This usually shows name *and* address of that person. " My (current) favourite attribution has this format: " "* Name
[date time]:" syn match Attribution "^*.*:$" contains=AddressEmail hi Attribution term=underline ctermfg=Red ctermbg=black " Emphasis: Emphasized words with *asterisks* around. syn match Emphasized "\*\w\+\*" hi Emphasized term=underline ctermfg=Red ctermbg=black " Hyphenation: Dashes at the end of lines, indicating hyphenated words. syn match Hyphenation "\w\+-$" hi Hyphenation term=underline ctermfg=Red ctermbg=black " todo: Give the same coloring to the rest of the hyphenated word " on the next line. " Protected: Text that should not be broken like flow-text, eg tables. syn match Protected "^|" hi Protected term=underline ctermfg=Magenta ctermbg=black " PathFile: Filenames with leading path. " Examples: $HOME/.vimrc /usr/local/bin/gvim syn match PathFile "[$~a-zA-Z0-9\/._-]*/[$~a-zA-Z0-9/._-]\+" hi PathFile term=underline ctermfg=Magenta ctermbg=Black " Smileys: " syn keyword Smileys :-) ;-) :-/ :-( syn match Smileys "[:;]-[()/]" hi Smileys term=reverse ctermfg=Yellow ctermbg=Black " Snails: \@ @/ Beware - they eat signatures! " syn match Snails "\\*@/*" syn match Snails "\(\\@\|@\/\)" hi Snails term=reverse ctermfg=Yellow ctermbg=Black " Underline: _Underlined_ words. syn match Underline "_\w\+_" hi Underline term=underline ctermfg=Green ctermbg=Black " EndOfSentence: " Problem: How to match this at the end of the line? " syn match EndOfSentence "[\.:;!?]\+ *" " hi EndOfSentence term=bold ctermfg=LightRed ctermbg=Black " problem: this hides trailing whitespace. " probably needs to be "contained" in TrailWhitespace to work. " ShellExample: syn match ShellExample "^\s\+[$%#] .*" contains=PathFile hi ShellExample term=underline ctermfg=Green ctermbg=Black " VimlExample: syn match VimExample "^\s\+:.*" contains=PathFile hi VimExample term=underline ctermfg=Green ctermbg=Black " SignOff: How I usually sign a message. " Example: "Sven [editing emails]" syn match SignOff "^Sven\s\+\[.*\]" contains=Smileys,programs hi SignOff term=underline ctermfg=Red ctermbg=Black " ====== " HEADER " ====== syn case ignore syn match HeaderDate contained "^Date: .*" hi HeaderDate ctermfg=LightBlue ctermbg=Black syn match HeaderRef contained "^\(In-Reply-To\|References\): .*" hi HeaderRef ctermfg=DarkBlue ctermbg=Black " Note: I have chosen dark colors here as I do not want to see thus line. syn match HeaderSubject contained "^Subject: .*" contains=AddressWeb,AddressEmail,programs hi HeaderSubject ctermfg=White ctermbg=Red syn match HeaderNewsgroups contained "^Newsgroups: .*" contains=programs hi HeaderNewsgroups ctermbg=Black ctermfg=Yellow " syn match HeaderXtra contained "^X-[a-zA-Z0-9\.-]: .*" contains=AddressWeb,AddressEmail,programs syn match HeaderXtra contained "^X-\w\+: .*" contains=AddressWeb,AddressEmail,programs hi HeaderXtra ctermfg=Red ctermbg=Black " colorize even when there is no space following the header line yet: syn match HeaderAddress contained "^\(From\|To\|Cc\|Bcc\|Reply-To\):.*" contains=AddressEmail,TrailWhitespace " space required after the colon for colorization: " syn match HeaderAddress contained "^\(From\|To\|Cc\|Bcc\|Reply-To\): .*" contains=AddressEmail,TrailWhitespace " syn region HeaderAddress contained start="^\(From\|To\|Cc\|Bcc\|Reply-To\): .*" skip="^\s\+.*[^,]$" end="[^,]$"me=s-1 contains=AddressEmail,TrailWhitespace " syn region HeaderAddress contained start="^\(From\|To\|Cc\|Bcc\|Reply-To\): .*" skip=",$" end="[^,]$" contains=AddressEmail,TrailWhitespace " syn region HeaderAddress contained start="^\(From\|To\|Cc\|Bcc\|Reply-To\): .*" skip=",$" end="$" hi HeaderAddress ctermfg=Green ctermbg=Black " syn region Header start="^From " skip="^[ \t]" end="^[-A-Za-z0-9]*[^-A-Za-z0-9:]"me=s-1 end="^[^:]*$"me=s-1 end="^---*" contains=Header,HeaderSubject " syn region Header start="^\(Newsgroups\|From\|To\|Cc\|Bcc\|Reply-To\|Subject\|Return-Path\|Received\|Date\|Replied\): " skip="^\s" end="^[-a-z0-9]*[^-a-z0-9:]"me=s-1 end="^[^:]*$"me=s-1 end="^---*" contains=HeaderAddress,HeaderSubject,HeaderDate,HeaderRef,HeaderXtra,Smileys,AddressEmail,AddressWeb " syn region Header start="^\(From\|To\|Cc\|Bcc\|Reply-To\|Subject\|Message-Id\|Newsgroups\|Return-Path\|Received\|Date\|Replied\): " end="^$" contains=HeaderAddress,HeaderNewsgroups,HeaderSubject,HeaderDate,HeaderRef,HeaderXtra,Smileys,AddressEmail,AddressWeb " syn region Header start="^[\w-]\+: " end="^$" contains=HeaderAddress,HeaderNewsgroups,HeaderSubject,HeaderDate,HeaderRef,HeaderXtra,Smileys,AddressEmail,AddressWeb syn region Header start="^\(\w\|-\)\+: " end="^$" contains=HeaderAddress,HeaderNewsgroups,HeaderSubject,HeaderDate,HeaderRef,HeaderXtra,Smileys,AddressEmail,AddressWeb hi Header ctermfg=Cyan guifg=Cyan " AddressEmail: Email addresses " syn match AddressEmail "[a-zA-Z0-9\.-]\+@[a-zA-Z0-9\.-]\+" " syn match AddressEmail contained "\(\k\|[._-]\)\+@\(\k\|[._-]\)\+" " syn match AddressEmail "\(\k\|[._-]\)\+@\(\k\|[._-]\)\+" " the following requires at least one dot in the string: syn match AddressEmail "\(\k\|[._-]\)\+@\(\k\|[._-]\)\+\.\k\+" hi AddressEmail term=underline ctermfg=Magenta ctermbg=Black " AddressWeb: WWW addresses (aka URLs) " syn match AddressWeb contained "\(ftp\|http\|telnet\)://[a-zA-Z0-9\./~#-]\+" contains=programs syn match AddressWeb "\(ftp\|http\|telnet\)://\(\w\|[./~#_-]\)\+" contains=programs " hi AddressWeb ctermfg=Magenta guifg=Magenta hi AddressWeb term=underline ctermfg=Green ctermbg=Black " ====== " BODY " ====== " Sigdashes: Lines that indicate the start of a signature, ie "-- ". syn match Sigdashes "^-- $" contained hi Sigdashes term=underline ctermfg=Red ctermbg=Grey " Signature: A proper signature (usually at the very end of the text). syn region Signature start="^-- $" end="^$" contains=Sigdashes,8bitChars,TABS,TrailWhitespace,programs,sveng,AddressWeb,AddressEmail hi Signature term=reverse ctermfg=Black ctermbg=Grey " QuotedSignature: A proper signature in quoted text. " Order: Must be defined *after* QuotedText! syn region QuotedSignature start="^[> ]\+-- *$" end="^[> ]*$" contains=8bitChars,TABS,TrailWhitespace,programs,sveng,AddressWeb,AddressEmail hi QuotedSignature term=reverse ctermfg=Magenta ctermbg=Grey " QuotedText: Properly quoted text (ie lines starting with "> "): " TODO: Add levels of quoting and colorize in alternate fashion. syn match QuotedText "^> .*" contains=8bitChars,TABS,TrailWhitespace,programs,sveng,AddressWeb,AddressEmail,QuotedSignature hi QuotedText ctermbg=Black ctermfg=Cyan guifg=Cyan " NormalText: Non-quoted text. " syn match NormalText "[^>].*" contains=Indentation,8bitChars,TABS,TrailWhitespace,programs,sveng,AddressWeb,AddressEmail,Signature " hi NormalText ctermfg= guifg= " ControlChars: Control characters except tabs (ASCII 1-8 10-31) " Example: [ ] (hmm, this somehow doen't work) " syn match ControlChars contained "[--]" "                      " syn match ControlChars "[--]" " syn match ControlChars "[ ]" " hi ControlChars ctermfg=Red guifg=Red " 8bitChars: Characters with 8th bit set (ASCII 128-255). " Example: [äöüæ¤] " syn match 8bitChars contained "[€-ÿ]" syn match 8bitChars "[€-ÿ]" hi 8bitChars ctermfg=Red guifg=Red " syn keyword programs elm irc less lynx mutt pine procmail screen slrn vim zsh syn match programs "\(elm\|gvim\|irc\|less\|lynx\|mutt\|pine\|procmail\|screen\|slrn\|vim\|zsh\)\(\d\|[.-]\)*" hi programs ctermbg=Black ctermfg=Red guifg=Red " ====== " TEST " ====== " syn case ignore " syn keyword sveng Sven Guckes " hi sveng ctermbg=Red guibg=Red let b:current_syntax = "sven" " The last line is a "modeline" - see ":help modelines"! " vim: ts=8 comments=n\:\"