2 " Language: none; used to see highlighting
3 " Maintainer: Ronald Schild <rs@scutum.de>
4 " Last Change: 1999 Jul 07
7 " To see your current highlight settings, do
8 " :so $VIMRUNTIME/syntax/hitest.vim
10 " save global options and registers
11 let save_hidden = &hidden
12 let save_lazyredraw = &lazyredraw
14 let save_report = &report
15 let save_shortmess = &shortmess
16 let save_wrapscan = &wrapscan
17 let save_register_a = @a
18 let save_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 set autoindent noexpandtab formatoptions=t shiftwidth=16 noswapfile tabstop=16
38 let &textwidth=&columns
40 " insert highlight settings
44 " remove color settings (not needed here)
45 global! /links to/ substitute /\s.*$//e
47 " move linked groups to the end of file
48 global /links to/ move $
50 " move linked group names to the matching preferred groups
51 % substitute /^\(\w\+\)\s*\(links to\)\s*\(\w\+\)$/\3\t\2 \1/e
52 global /links to/ normal mz3ElD0#$p'zdd
57 " precede syntax command
58 % substitute /^[^ ]*/syn keyword &\t&/
60 " execute syntax commands
65 " remove syntax commands again
66 % substitute /^syn keyword //
69 global /^/ exe "normal Wi\<CR>\t\eAA\ex"
72 " find out first syntax highlighting
73 let b:various = &highlight.',:Normal,:Cursor,:,'
75 while b:various =~ ':'.substitute(getline(b:i), '\s.*$', ',', '')
77 if b:i > line("$") | break | endif
81 call append(0, "Highlighting groups for various occasions")
82 call append(1, "-----------------------------------------")
85 let b:synhead = "Syntax highlighting groups"
86 if exists("hitest_filetypes")
90 let @a = substitute(@a, 'did_\(\w\+\)_syn\w*_inits\s*#1', ', \1', 'g')
91 let @a = substitute(@a, "\n\\w[^\n]*", '', 'g')
92 let @a = substitute(@a, "\n", '', 'g')
93 let @a = substitute(@a, '^,', '', 'g')
95 let b:synhead = b:synhead." - filetype"
97 let b:synhead = b:synhead."s"
99 let b:synhead = b:synhead.":".@a
102 call append(b:i+1, "")
103 call append(b:i+2, b:synhead)
104 call append(b:i+3, substitute(b:synhead, '.', '-', 'g'))
107 " remove 'hls' highlighting
111 " add autocommands to remove temporary file from buffer list
114 au BufUnload Highlight\ test if expand("<afile>") == "Highlight test"
115 au BufUnload Highlight\ test bdelete! Highlight\ test
116 au BufUnload Highlight\ test endif
117 au VimLeavePre * if bufexists("Highlight test")
118 au VimLeavePre * bdelete! Highlight\ test
119 au VimLeavePre * endif
122 " we don't want to save this temporary file
125 " the following trick avoids the "Press RETURN ..." prompt
129 " restore global options and registers
130 let &hidden = save_hidden
131 let &lazyredraw = save_lazyredraw
132 let &more = save_more
133 let &report = save_report
134 let &shortmess = save_shortmess
135 let &wrapscan = save_wrapscan
136 let @a = save_register_a
138 " restore last search pattern
139 call histdel("search", -1)
140 let @/ = save_register_se
143 unlet save_hidden save_lazyredraw save_more save_report save_shortmess
144 unlet save_wrapscan save_register_a save_register_se