syn-preproc : C preprocessor syntax on top of other syntaxes.
| script karma
Downloaded by 60
Comments, bugs, improvements
script versions (upload new version)
This syntax extension highlights C preprocessor directives and (optionally)
folds preprocessor conditions. You can use this as a standalone syntax, or add
this on top of another filetype.
If you have certain files of a particular filetype (e.g. Tcl) that contain
preprocessing directives, you can add a custom filetype detection (here: for a
"Tcl template" .tclt file extension; cp. new-filetype), and set a compound
autocmd BufNewFile,BufRead *.tclt setf tcl.preproc
To add the highlighting to the file's existing syntax, use:
To just have preprocessing highlighting (and no other syntax), use:
Note: This script supports both the normal "#..." syntax as well as the
alternative "%:..." digraph (or alternative token) for the '#' punctuator.
This script is packaged as a vimball. If you have the "gunzip" decompressor
in your PATH, simply edit the *.vmb.gz package in Vim; otherwise, decompress
the archive first, e.g. using WinZip. Inside Vim, install by sourcing the
vimball or via the :UseVimball command.
To uninstall, use the :RmVimball command.
- Requires Vim 7.0 or higher.
For a permanent configuration, put the following commands into your vimrc:
C/C++-style comments are typically removed by the preprocessor and thus
highlighted as other comments. You can define a different highlighting if you
want to visually distinguish them from the default comments of that filetype:
hi link preprocComment NonText
Or turn highlighting of comments off:
let preproc_no_comments = 1
Multi-line C-style comments are folded; if you do not want this, use:
let preproc_no_comment_fold = 1
To turn off folding of #if ... #endif conditions, use:
:let preproc_no_fold_conditions = 1
Lines commented out via #if 0 will still be folded. To turn that of, too,
:let preproc_no_if0_fold = 1
To completely turn off highlighting (as comments) of #if 0 blocks, use:
:let preproc_no_if0 = 1
Click on the package to download.
ip used for rating: 22.214.171.124