Vim: colorscheme in Python

I am using Mac OSX Lion 10.7.2, Terminal.app supports 256 (output: echo & t_Co). In my vimrc I have (PATH / TO / vim / vimrc)

syntax on filetype plugin indent on set nobackup 

When I "vim blah.py" and :colorscheme torte , syntax colors do not load. For example, the python keyword does not have the correct colors (they have the usual text color). This works for .c files, but not python.

I updated my /python.vim syntax but still no luck.

Can someone tell me why?

thanks

+7
source share
4 answers

markfw

Your answer is very good, but let me add one thing to it. In .vimrc instead of adding only

 let python_highlight_all=1 

you have to add it this way

 autocmd BufRead,BufNewFile *.py let python_highlight_all=1 

Thus, this only applies to Python files.

I hope for this help.

+6
source

if it works in c but not py, the filetype file and / or syntax file are not in the right place for python.

the vim manual should help you, but I will also try the command :scr . All downloaded vim scripts are listed here. So you start vim in two ways.

vim your.c

vim your.py

and then in each vim session type: scr. see how the syntax file for C is loaded (it's like a chain reaction) and why it doesn't work so that python can give you the key.

+7
source

The way I worked (I use Terminal) should have let python_highlight_all = 1 in my ~ / .vimrc file, and now everything works fine, and all objects like list, tuple, ... are colored.

See the / python.vim syntax for more information.

+7
source

Try adding the following lines to ~ / .vimrc:

 set nocompatible filetype on syntax enabled 

Close and restart Vim or run :so ~/.vimrc to reload the settings.

nocompatible remove compatibility with the original vi, it is recommended to get a fully functional Vim. filetype on enable automatic detection of file type, this is the parameter that you want your Python code to be colored. syntax enabled activate code coloring, but I'm not sure if this is mandatory here.

You can get more help by typing :help filetype in Vim.

+4
source

All Articles