sponsor Vim development Vim logo Vim Book Ad

ifdef highlighting : #ifdef highlighting in c/c++/idl

 script karma  Rating 173/73, Downloaded by 8413  Comments, bugs, improvements  Vim wiki

created by
Michael Geddes
 
script type
syntax
 
description
Provides highlighting for  #ifdef  #ifndef  #else  #endif  blocks, with the ability to mark a symbol as defined or undefined.
Handles nesting of #ifdefs (and #if) as well, but does not handle  #if defined().

Supports vim_ifdef:  modelines and .defines (_defines for win16/win32s) files to specify defined/undefined symbols.

use :Define <keyword>  or  :Undefine <keyword>     to dynamically specify defined or undefined sections.
 
install details
Place in syntax/ directory within your runtime path.

Can be invoked by appending .ifdef to your syntax.
eg with a modeline   vim: syntax=c.ifdef

Alternatively, call from a syntax file after/syntax/c.vim (or cpp.vim or idl.vim)
 

rate this script Life Changing Helpful Unfulfilling 
script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
ifdef.vim 3.2 2011-07-19 7.0 Michael Geddes Fix from Dr Chip (handle closing */ on next line after #ifdef)
ifdef.vim 3.1 2011-07-03 7.0 Michael Geddes - Wu Hong fixed bug in Undefine() colouring
- Stop errors in script due to undefined hl being cleared.
- Added :Define, :Undefine with completion
ifdef.vim 3.0 2004-08-06 6.0 Michael Geddes - Renamed everything to be more clear, and reversed some of the include
groups from exclude groups

- make use of ALL in groups. This seems to have fixed most bugs, but may have reintroduced some as well, however doing it this way round should prevent most interaction with other scripts.

- Actually clear the cPreCondit highlight gtoup as we are taking it over.
  Ditto cCppOut (#if 0) handling
ifdef.vim 2.3 2004-02-01 6.0 Michael Geddes - Clean up some of the comments
- Add comments for hilighting groups.
- Ignore whitespace in .defines files. (TODO: Credit person who suggested this!)
ifdef.vim 2.2 2004-01-29 6.0 Michael Geddes - Add support for idl files.
- Suggestions from ??? (let me know if this was you)
    - Check for 'shell' type and 'shellslash'
    - Don't use has(\"windows\")
ifdef.vim 2.1 2003-01-01 6.0 Michael Geddes Minor bugfixes (use :p modifier in getting directory)
- suggestions from Erik R.  
Documentation updates
ifdef.vim 2.0 2002-12-29 6.0 Michael Geddes - Added loading of ifdefs
  - via ifdef modelines
  - via .defines files
- Added missing highlight link.. relinked ifdefed out comments to Debug
- Conditional loading of functions
ifdef.vim 1.3 2002-12-18 6.0 Michael Geddes Fix up some group names so colours get picked up.
ip used for rating: 142.132.191.50

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.
   
Vim at Github