blob: 8f5ea71a367d569d8e84d04c4bcbb1268f46ec21 [file] [log] [blame]
Bram Moolenaar071d4272004-06-13 20:20:40 +00001" Vim syntax file
2" Language: Rich Text Format
3" "*.rtf" files
4"
5" The Rich Text Format (RTF) Specification is a method of encoding formatted
6" text and graphics for easy transfer between applications.
7" .hlp (windows help files) use compiled rtf files
8" rtf documentation at http://night.primate.wisc.edu/software/RTF/
9"
10" Maintainer: Dominique Stéphan (dominique@mggen.com)
11" URL: http://www.mggen.com/vim/syntax/rtf.zip
12" Last change: 2001 Mai 02
13
14" TODO: render underline, italic, bold
15
16" For version 5.x: Clear all syntax items
17" For version 6.x: Quit when a syntax file was already loaded
18if version < 600
19 syntax clear
20elseif exists("b:current_syntax")
21 finish
22endif
23
24" case on (all controls must be lower case)
25syn case match
26
27" Control Words
28syn match rtfControlWord "\\[a-z]\+[\-]\=[0-9]*"
29
30" New Control Words (not in the 1987 specifications)
31syn match rtfNewControlWord "\\\*\\[a-z]\+[\-]\=[0-9]*"
32
33" Control Symbol : any \ plus a non alpha symbol, *, \, { and } and '
34syn match rtfControlSymbol "\\[^a-zA-Z\*\{\}\\']"
35
36" { } and \ are special characters, to use them
37" we add a backslash \
38syn match rtfCharacter "\\\\"
39syn match rtfCharacter "\\{"
40syn match rtfCharacter "\\}"
41" Escaped characters (for 8 bytes characters upper than 127)
42syn match rtfCharacter "\\'[A-Za-z0-9][A-Za-z0-9]"
43" Unicode
44syn match rtfUnicodeCharacter "\\u[0-9][0-9]*"
45
46" Color values, we will put this value in Red, Green or Blue
47syn match rtfRed "\\red[0-9][0-9]*"
48syn match rtfGreen "\\green[0-9][0-9]*"
49syn match rtfBlue "\\blue[0-9][0-9]*"
50
51" Some stuff for help files
52syn match rtfFootNote "[#$K+]{\\footnote.*}" contains=rtfControlWord,rtfNewControlWord
53
54" Define the default highlighting.
55" For version 5.7 and earlier: only when not done already
56" For version 5.8 and later: only when an item doesn't have highlighting yet
57if version >= 508 || !exists("did_rtf_syntax_inits")
58 if version < 508
59 let did_rtf_syntax_inits = 1
60 command -nargs=+ HiLink hi link <args>
61 else
62 command -nargs=+ HiLink hi def link <args>
63 endif
64
65
66 HiLink rtfControlWord Statement
67 HiLink rtfNewControlWord Special
68 HiLink rtfControlSymbol Constant
69 HiLink rtfCharacter Character
70 HiLink rtfUnicodeCharacter SpecialChar
71 HiLink rtfFootNote Comment
72
73 " Define colors for the syntax file
74 hi rtfRed term=underline cterm=underline ctermfg=DarkRed gui=underline guifg=DarkRed
75 hi rtfGreen term=underline cterm=underline ctermfg=DarkGreen gui=underline guifg=DarkGreen
76 hi rtfBlue term=underline cterm=underline ctermfg=DarkBlue gui=underline guifg=DarkBlue
77
78 HiLink rtfRed rtfRed
79 HiLink rtfGreen rtfGreen
80 HiLink rtfBlue rtfBlue
81
82 delcommand HiLink
83endif
84
85
86let b:current_syntax = "rtf"
87
88" vim:ts=8