Wikia

Vim Tips Wiki

Changes: Changing the default syntax highlighting

Edit

Back to page

(Comments)
(Reduce syncolor mention.)
 
Line 34: Line 34:
 
*[[VimTip1120|1120 Remove annoyance with syntax highlighting when starting a string]]
 
*[[VimTip1120|1120 Remove annoyance with syntax highlighting when starting a string]]
   
==Changing-distribution-syncolor.vim==
+
===Changing syncolor.vim===
+
It is possible to replace Vim's syncolor.vim file to customise syntax highlighting. {{help|syncolor}} See [[Highlight special filetype docs]] which includes a comment that a syncolor.vim alternative is [[User:Donald j axel/syncolor|available here]]. --March 9, 2013
Even if you compile vim from scratch it is best to save a default syntax-coloring in a file named e.g. syncolor.vim.local or just syncolor.loc and then copy that file over vim's syncolor.vim thereby destroying the syncolors which you wouldn't use anyway. Of course you could save a copy of the original first or get a new one from the source distribution.
 
A very neutral and helpful colour-scheme which has been used with gratitude by all my users is a scheme where comments are green and keywords are bold blue etc. This seems to give gvim/vim a look and feel which most people appreciate:
 
https://docs.google.com/file/d/0BxtWx2h12yVPOEUzTUFscWp0VVU/edit?usp=sharing
 
 
Most suitable for xterm with wheat or cornsilk (light) background.
 
Hope you'll like it. Regards, Donald Axel (donald.axel on gmail).
 

Latest revision as of 01:34, March 10, 2013

Tip 24 Printable Monobook Previous Next

created 2001 · complexity intermediate · version 6.0


Vim provides syntax files that can provide syntax coloring or folding for certain types of files. This tip discusses how to change some features of the standard syntax files to suit a personal preference. Do not change any of the files distributed with Vim because such updates will be lost when Vim is updated. Instead, use the techniques discussed here.

DocumentationEdit

Here are some pointers to the Vim documentation on syntax highlighting.

Python triple-quoted commentsEdit

In Vim 7.3 the file vim73/syntax/python.vim provides syntax highlighting for Python files. That file (correctly) treats """...""" as a string and highlights it accordingly. If you prefer, instances of """...""" or '''...''' that start on the line following a line ending with a colon can be treated as a comment. To do that, create file python.vim in your "after" syntax directory as in the following. The next Python file you open should treat triple-quoted doc strings in functions as comments (assuming your vimrc includes commands like filetype indent plugin on and syntax on).

Add the following to file ~/.vim/after/syntax/python.vim (Unix) or $HOME/vimfiles/after/syntax/python.vim (Windows)—you may need to create the directories and the file.

syn region pythonComment
      \ start=+\%(:\n\s*\)\@<=\z('''\|"""\)+ end=+\z1+ keepend
      \ contains=pythonEscape,pythonTodo,@Spell

CommentsEdit

This tip is vaguely related:

Changing syncolor.vimEdit

It is possible to replace Vim's syncolor.vim file to customise syntax highlighting. :help syncolor See Highlight special filetype docs which includes a comment that a syncolor.vim alternative is available here. --March 9, 2013

Around Wikia's network

Random Wiki