MediaWiki syntax highlighting with Vim

From FVue
Jump to: navigation, search


I want to show my code in MediaWiki with syntax highlighting.



Install the Vim MediaWiki Syntax highlighting extension.


Follow this procedure:

  1. Load the code in Vim
  2. Issue these Vim commands:
:syntax on                  " Make sure syntax highlighting is enabled
:set nonumber               " Disable possible line numbering
:colorscheme default        " Use the default colors
:runtime! syntax/2html.vim  " Convert to HTML (or from gVim menu: {Syntax | Convert to HTML})
:%s/<br>$//                 " Remove 
's at end of line
  1. Manually remove possible generated HTML-links which have been generated out of http:// links in code.
  2. Within the resulting HTML file, indent the contents of the <body> block with one space.
  3. Copy the contents of the <body> block to MediaWiki. Leave out the outer 'monospace' definition.

See also

VIM Color Scheme Test
284 Vim color scheme examples on one page



Found Vim syntax highlighing extension in MediaWiki subversion repository.


Tried setting a different color scheme, e.g. `pablo':

$/var/lib/mediawiki-1.11.0/extensions/SyntaxHighlight_vim> cat vimrc.vim
syntax on
set encoding=utf8
set uc=0 " Disable swap files
set background=dark
colorscheme pablo

but it appears all gui colors are converted to the standard set of 16 non-gui terminal colors.

You can use css by specifying in vimrc.vim:

let html_use_css=1


blog comments powered by Disqus