Reputation: 683
I'm using Mac OSX Lion 10.7.2, Terminal.app supports 256 (output of :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 are not loading. For example python keyword doesn't have a proper colors (They have regular text color). That works for .c files but not python.
I updated my syntax/python.vim but still no luck.
Can someone tell me why?
Upvotes: 9
Views: 8651
Reputation: 574
markfw
Your answer is very good but let me just add one thing to it. In your .vimrc
instead of adding just
let python_highlight_all=1
you should add it this way
autocmd BufRead,BufNewFile *.py let python_highlight_all=1
This way it only applies to Python file(s).
Hope this help.
Upvotes: 8
Reputation: 683
The way that I made it to work (I'm using Terminal) is to have let python_highlight_all = 1
in my ~/.vimrc file and now everything works fine and all objects such as list, tuple, ... are colored.
For more information please look at the syntax/python.vim.
Upvotes: 7
Reputation: 818
Try to add the following lines to your ~/.vimrc:
set nocompatible
filetype on
syntax enabled
Quit and relaunch Vim or execute :so ~/.vimrc
to reload the settings.
nocompatible
remove compatibility with the original vi, this is recommended to get a fully functional Vim.
filetype on
activate automatic file type detection, this is the option you want for your Python code to be colored.
syntax enabled
activate code coloring, but i'm not sure if this is mandatory here.
You can get some more help by typing :help filetype
in Vim.
Upvotes: 5
Reputation: 6244
if it works in c but not on py, the filetype file and/or syntax file is not at the right location for python.
vim manual should help you, but I also would try :scr
command. This lists all the vim script loaded. So you start vim in two different way
vim your.c
vim your.py
and then in each vim session, type :scr. see how the syntax file for C is loaded (it is like chain reaction), and why it doesnt work that way for python may give you clue.
Upvotes: 7