Vim Color Improved is a syntax highlighting plugin that allows you to include code from local or reomte files in your WordPress posts.
It uses the same tag and parameter parsing as the popular CodeViewer 1.4, and should be compatible with it’s options. In addition, any of the optional parameters from codeviewer 1.4 can be set as defaults, which can then be overriden by parameters in the tag. Vim Color Improved outputs code in <pre> formatted blocks, rather than ordered lists, which can be difficult to copy and paste, and can syntax highlight any language which vim supports.
Vim Color Improved contains a sophisticated caching system that stores the generated html to the filesystem. This greatly reduces the time required to display the code. In addition, it checks the modified time on both local and remote files to ensure that cached information is up-to-date. If it is unable to access the source code, and there is a cached version available, it will display the cached version with a notice.
Using Vim Color Improved
(These instructions basically parallel those for CodeViewer 1.4)
Vim Color Improved searches your post for a custom tag named [viewcode ] [/viewcode], that tells the server to look at an external file and parse it into syntax higihlighted html. It can be placed anywhere a block-level tag is valid but the tag must be properly closed.
Note that there should not be a white space character after viewcode and before ].
[viewcode] src=”URI or path to local file” link=yes|no lines= scroll=yes|no scrollheight=valid css height showsyntax=yes|no cache=yes|no[/viewcode]
Default values for all of these parameters, other than src can be set in the options page.
The src attribute is required.
src – string – The URI or path to a local file of the code to display. Note that relative paths are in relation to the default_path set in the options page. This default value is set to the directory your blog is installed in.
The link attribute is optional.
link – string – Should the link to the code be displayed (yes), or not be displayed (no). If the link attribute is left out of the tag completely, the value defaults to no.
The lines attribute is optional.
lines – string – Which linenumbers shall be visible in the output. Use , and – to separate linenumbers. Example: lines=1,3-5,10-12,16-18,22.
The scroll attribute is optional.
scroll – string – Should the scrollbar be displayed (yes), or not be displayed (no).
The scrollheight attribute is optional.
height – string – Height of the scrollbar. Any valid css height declaration can be used. Example: 100px or 50em
The showsyntax attribute is optional.
showsyntax – string – Should the syntax used of [viewcode ] be displayed (yes), or not be displayed (no).
These are new parameters that can be used by Vim Color Improved.
The cache attribute is optional.
cache – string – Cache this code block (yes) or not (no).
The html_use_css attribute is optional.
html_use_css – string – This is a parameter which is passed to vim, and affects the html that is output. Use css (yes) or not (no). If you chose to not use css, the code will be output in <span> tags with a style=”color:#xxxxxx” attribute, rather than a class.
All attribute values can optionally be surrounded with double quotes (“) or single quotes(‘).
Free Download: Download this wp-plugin