2 " Language: none; used to see highlighting
3 " Maintainer: Ronald Schild <rs@scutum.de>
4 " Last Change: 2001 Sep 02
7 " To see your current highlight settings, do
8 " :so $VIMRUNTIME/syntax/hitest.vim
10 " save global options and registers
11 let s:hidden = &hidden
12 let s:lazyredraw = &lazyredraw
14 let s:report = &report
15 let s:shortmess = &shortmess
16 let s:wrapscan = &wrapscan
18 let s:register_se = @/
21 set hidden lazyredraw nomore report=99999 shortmess=aoOstTW wrapscan
23 " print current highlight settings into register a
28 " Open a new window if the current one isn't empty
29 if line("$") != 1 || getline(1) != ""
37 setlocal autoindent noexpandtab formatoptions=t shiftwidth=16 noswapfile tabstop=16
38 let &textwidth=&columns
40 " insert highlight settings
44 " remove the colored xxx items
47 " remove color settings (not needed here)
48 global! /links to/ substitute /\s.*$//e
50 " move linked groups to the end of file
51 global /links to/ move $
53 " move linked group names to the matching preferred groups
54 % substitute /^\(\w\+\)\s*\(links to\)\s*\(\w\+\)$/\3\t\2 \1/e
55 global /links to/ normal mz3ElD0#$p'zdd
60 " precede syntax command
61 % substitute /^[^ ]*/syn keyword &\t&/
63 " execute syntax commands
68 " remove syntax commands again
69 % substitute /^syn keyword //
72 global /^/ exe "normal Wi\<CR>\t\eAA\ex"
75 " find out first syntax highlighting
76 let b:various = &highlight.',:Normal,:Cursor,:,'
78 while b:various =~ ':'.substitute(getline(b:i), '\s.*$', ',', '')
80 if b:i > line("$") | break | endif
84 call append(0, "Highlighting groups for various occasions")
85 call append(1, "-----------------------------------------")
88 let b:synhead = "Syntax highlighting groups"
89 if exists("hitest_filetypes")
93 let @a = substitute(@a, 'did_\(\w\+\)_syn\w*_inits\s*#1', ', \1', 'g')
94 let @a = substitute(@a, "\n\\w[^\n]*", '', 'g')
95 let @a = substitute(@a, "\n", '', 'g')
96 let @a = substitute(@a, '^,', '', 'g')
98 let b:synhead = b:synhead." - filetype"
100 let b:synhead = b:synhead."s"
102 let b:synhead = b:synhead.":".@a
105 call append(b:i+1, "")
106 call append(b:i+2, b:synhead)
107 call append(b:i+3, substitute(b:synhead, '.', '-', 'g'))
110 " remove 'hls' highlighting
114 " add autocommands to remove temporary file from buffer list
117 au BufUnload Highlight\ test if expand("<afile>") == "Highlight test"
118 au BufUnload Highlight\ test bdelete! Highlight\ test
119 au BufUnload Highlight\ test endif
120 au VimLeavePre * if bufexists("Highlight test")
121 au VimLeavePre * bdelete! Highlight\ test
122 au VimLeavePre * endif
125 " we don't want to save this temporary file
128 " the following trick avoids the "Press RETURN ..." prompt
132 " restore global options and registers
133 let &hidden = s:hidden
134 let &lazyredraw = s:lazyredraw
136 let &report = s:report
137 let &shortmess = s:shortmess
138 let &wrapscan = s:wrapscan
139 let @a = s:register_a
141 " restore last search pattern
142 call histdel("search", -1)
143 let @/ = s:register_se
146 unlet s:hidden s:lazyredraw s:more s:report s:shortmess
147 unlet s:wrapscan s:register_a s:register_se