Encyclopedia > Wikipedia:Syntax highlighting

  Article Content

Wikipedia:Syntax highlighting

Many text editors have a feature called syntax highlighting, where various syntatical elements of the text are given different colours. Although this is most useful when editing source code, the method is equally applicable to editing wiki-markup. Below are instructions for installing Wikipedia syntax highlighting.

Vim

Click here to see what syntax highlighting in Vim looks like. Warning — the above link takes you directly to unfiltered HTML.

Save the target of the following link to your "syntax" directory. By default, this directory is "~/.vim/syntax" on a Unix system, and "C:\Program Files\Vim\vimfiles\syntax" on a Windows system.

Click here for wikipedia.vim

To autodetect files ending in ".wiki", add the following lines to ".vim/filetype.vim" or "vimfiles\filetype.vim" (or create the file if it doesn't exist):

augroup filetypedetect
au BufNewFile,BufRead *.wiki	setf wikipedia
augroup END

Alternatively, the command "set syn=wikipedia" will temporarily set the syntax for the current file.

If you are not familiar with Vim, here's some advice. Wikipedia articles often only have line-breaks at the end of each paragraph, a situation Vim is not designed for. The following lines added to your ".vimrc" or "_vimrc" file will make it much easier to edit such files:

set tw=0
set lbr
map <Up> gk
map <Down> gj
imap <Up> <ESC>gki
imap <Down> <ESC>gji

Please feel free to edit wikipedia.vim and upload an improved copy. This is a Wiki, after all.



All Wikipedia text is available under the terms of the GNU Free Documentation License

 
  Search Encyclopedia

Search over one million articles, find something about almost anything!
 
 
  
  Featured Article
Dynabee

... physics of this device looks confusing at first sight, but is surprisingly simple. It can easily be understood with a little knowledge of gyroscopes. The ...

 
 
 
This page was created in 38.5 ms