views:

510

answers:

4

I'm getting annoyed with the default python syntax highlighting in vim.

it does not highlight the else: statement correctly. vim only highlights the else statement if i have some white space between the "else" and the colon ":" so this works: "else :" but "else:" does not.

It must be easy to fix..

I'm using vim 7.2

+3  A: 

It should work by default.

Look for a file that is something like this:

/usr/share/vim/vim72/syntax/python.vim

There should be a line there that looks like this:

syn keyword pythonConditional   if elif else

If not, investigate further. Does elif work?

DisplacedAussie
+1  A: 

Enable the filetype stuff so things are setup automatically. I've python auto indenting and syntax highlighting setup for vim here: http://www.pixelbeat.org/settings/.vimrc

pixelbeat
+2  A: 

I had below statement in my vimrc file. This made else: be tokenized as one word. After removing that one line syntax highlighting works just fine.

set iskeyword+=:

Stephan
That's exactly right. Thanks, sir!
Bob
+1  A: 

Note that the file in

/usr/share/vim/vim72/syntax/python.vim

is not up to date for some reason.

Get the most recent version of the syntax highlight file from http://www.vim.org/scripts/script.php?script_id=790

Viktiglemma