Vim and python syntax question

Courageous jkraska1 at
Mon May 8 06:11:48 CEST 2000

Charles Boncelet wrote:
> When running vim with syntax coloring on, sometimes I get
> strong, dark colors and sometimes weak, pastel ones.  I
> have no idea why the colors vary.  Anyway, how can I always
> get the strong, dark colors?

The issue probably is *not* your vim syntax file, but rather
the defaults that your vim resolves to. I've included my
python.vim at the end of this, but what you probably really
want is my vimrc. On windows, you should name this "_vimrc"
and put it into the directory that your "%VIM%" environment
variable points to. On unix, call  it ".vimrc" and put it in
your home directory. For unix, you'll probably have to pick
new font descriptions. Note this is for gvim only...

syntax on
set hlsearch
source $VIM/syntax/syntax.vim
behave xterm
set guifont=Courier_New:h10
"set guifont=Lucida_Sans_Unicode:n:h9
set autoindent 
set noerrorbells 
set tabstop=4 
set wrapmargin=2 
set nowrap
set guioptions=am
set textwidth=150
set nobackup
set et

highlight String         guifg=Black      guibg=Yellow
highlight Constant       guifg=Blue                       font=Courier_New:b:h10
highlight PreCondit      guifg=Black                      font=Courier_New:b:h10
highlight PreProc        guifg=Firebrick                
highlight Define         guifg=Firebrick                
highlight Include        guifg=Black                      font=Courier_New:b:h10
highlight Type           guifg=Black                      font=Courier_New:b:h10
highlight Comment        guifg=Red                 
highlight Statement      guifg=Black                      font=Courier_New:b:h10
highlight Special        guifg=Black                      font=Courier_New:b:h10
highlight Identifier     guifg=Black               
highlight Number         guifg=Blue                       font=Courier_New:b:h10
highlight Operator       guifg=Black                      font=Courier_New:b:h10
highlight Error          guifg=Black      guibg=Red
highlight pythonSpecial  guifg=Blue                       font=Courier_New:b:h10

highlight link Character   String
highlight link Function    Statement
highlight link Label       Type

" Vim syntax file
" Language:	Python
" Maintainer:	Neil Schemenauer <nascheme at>
" Last change:	1998 July 17

" Remove any old syntax stuff hanging around
syn clear

syn keyword pythonStatement		break continue del
syn keyword pythonStatement		except exec finally
syn keyword pythonStatement		pass print raise
syn keyword pythonStatement		return try
syn keyword pythonStatement		global assert
syn keyword pythonRepeat		for while
syn keyword pythonConditional		if elif else then
syn keyword pythonOperator		and in is not or
syn keyword pythonConstant		None
syn region  pythonString		start=+'+  end=+'+ skip=+\\\\\|\\'+
syn region  pythonString		start=+"+  end=+"+ skip=+\\\\\|\\"+
syn region  pythonString		start=+"""+  end=+"""+
syn region  pythonString		start=+'''+  end=+'''+
syn keyword pythonFunction		def class lambda
syn keyword pythonPreCondit		import from
syn match   pythonComment		"#.*$" contains=pythonTodo
syn keyword pythonTodo			contained TODO FIXME XXX
syn match   pythonList                  "[\[\]]"
syn match   pythonDict                  "[{}]"
syn match   pythonNumber                "\<\(0[0-7]*\|0[xX]\x\+\|\d\+\)[lL]\=\>"
syn match   pythonNumber                "\(\<\d\+\.\d*\|\.\d\+\)\([eE][-+]\=\d\+\)\=[fFdD]\="
syn match   pythonNumber                "\<\d\+[eE][-+]\=\d\+[fFdD]\=\>"

" triple quoted strings make syncronizing difficult
"syn sync match pythonSync1 grouphere NONE +\("""$\)\|\('''$\)+
syn sync match pythonSync grouphere NONE "):$"
syn sync maxlines=100

if !exists("did_python_syntax_inits")
  let did_python_syntax_inits = 1
  " The default methods for highlighting.  Can be overridden later
  hi link pythonDict		        pythonSpecial
  hi link pythonList		        pythonSpecial
  hi link pythonNumber		        Number
  hi link pythonStatement		Statement
  hi link pythonConditional		Conditional
  hi link pythonConstant		Constant
  hi link pythonRepeat			Repeat
  hi link pythonString			String
  hi link pythonOperator		Operator
  hi link pythonFunction		Function
  hi link pythonPreCondit		PreCondit
  hi link pythonComment			Comment
  hi link pythonTodo			Todo

let b:current_syntax = "python"

" vim: ts=8

More information about the Python-list mailing list