home *** CD-ROM | disk | FTP | other *** search
/ vim.ftp.fu-berlin.de / 2015-02-03.vim.ftp.fu-berlin.de.tar / vim.ftp.fu-berlin.de / mac / vim55rt.sit / runtime / syntax / hitest.vim < prev    next >
Encoding:
Text File  |  1999-09-25  |  3.7 KB  |  147 lines  |  [TEXT/VIM!]

  1. " Vim syntax file
  2. " Language:    none; used to see highlighting
  3. " Maintainer:    Ronald Schild <rs@scutum.de>
  4. " Last change:    1999 Jul 07
  5. " Version:    5.4n.1
  6.  
  7. " To see your current highlight settings, do
  8. "    :so $VIMRUNTIME/syntax/hitest.vim
  9.  
  10. " save global options and registers
  11. let save_hidden      = &hidden
  12. let save_lazyredraw  = &lazyredraw
  13. let save_more        = &more
  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 = @/
  19.  
  20. " set global options
  21. set hidden lazyredraw nomore report=99999 shortmess=aoOstTW wrapscan
  22.  
  23. " print current highlight settings into register a
  24. redir @a
  25. highlight
  26. redir END
  27.  
  28. " Open a new window if the current one isn't empty
  29. if line("$") != 1 || getline(1) != ""
  30.   new
  31. endif
  32.  
  33. " edit temporary file
  34. edit Highlight\ test
  35.  
  36. " set local options
  37. set autoindent noexpandtab formatoptions=t shiftwidth=16 noswapfile tabstop=16
  38. let &textwidth=&columns
  39.  
  40. " insert highlight settings
  41. % delete
  42. put a
  43.  
  44. " remove color settings (not needed here)
  45. global! /links to/ substitute /\s.*$//e
  46.  
  47. " move linked groups to the end of file
  48. global /links to/ move $
  49.  
  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
  53.  
  54. " delete empty lines
  55. global /^ *$/ delete
  56.  
  57. " precede syntax command
  58. % substitute /^[^ ]*/syn keyword &\t&/
  59.  
  60. " execute syntax commands
  61. syntax clear
  62. % yank a
  63. @a
  64.  
  65. " remove syntax commands again
  66. % substitute /^syn keyword //
  67.  
  68. " pretty formatting
  69. global /^/ exe "normal Wi\<CR>\t\eAA\ex"
  70. global /^\S/ join
  71.  
  72. " find out first syntax highlighting
  73. let b:various = &highlight.',:Normal,:Cursor,:,'
  74. let b:i = 1
  75. while b:various =~ ':'.substitute(getline(b:i), '\s.*$', ',', '')
  76.    let b:i = b:i + 1
  77.    if b:i > line("$") | break | endif
  78. endwhile
  79.  
  80. " insert headlines
  81. call append(0, "Highlighting groups for various occasions")
  82. call append(1, "-----------------------------------------")
  83.  
  84. if b:i < line("$")-1
  85.    let b:synhead = "Syntax highlighting groups"
  86.    if exists("hitest_filetypes")
  87.       redir @a
  88.       let
  89.       redir END
  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')
  94.       if @a != ""
  95.          let b:synhead = b:synhead." - filetype"
  96.          if @a =~ ','
  97.             let b:synhead = b:synhead."s"
  98.          endif
  99.          let b:synhead = b:synhead.":".@a
  100.       endif
  101.    endif
  102.    call append(b:i+1, "")
  103.    call append(b:i+2, b:synhead)
  104.    call append(b:i+3, substitute(b:synhead, '.', '-', 'g'))
  105. endif
  106.  
  107. " remove 'hls' highlighting
  108. nohlsearch
  109. normal 0
  110.  
  111. " add autocommands to remove temporary file from buffer list
  112. aug highlighttest
  113.    au!
  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
  120. aug END
  121.  
  122. " we don't want to save this temporary file
  123. set nomodified
  124.  
  125. " the following trick avoids the "Press RETURN ..." prompt
  126. 0 append
  127. .
  128.  
  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
  137.  
  138. " restore last search pattern
  139. call histdel("search", -1)
  140. let @/ = save_register_se
  141.  
  142. " remove variables
  143. unlet save_hidden save_lazyredraw save_more save_report save_shortmess
  144. unlet save_wrapscan save_register_a save_register_se
  145.  
  146. " vim: ts=8
  147.