text editor suggestion?

sjdevnull at yahoo.com sjdevnull at yahoo.com
Tue Aug 22 04:13:25 EDT 2006


John Salerno wrote:
>
> The thing I liked about UltraEdit is that you can define your own groups
> of words and put whatever words you want in there, so my file had a
> group called '__builtins__' and it listed all the Python built-in
> methods, and those would be highlighted. Most editors I see don't seem
> to allow this...they just figure out what a function or method is on
> their own somehow.

In vim, you can just put "let python_highlight_builtins=1" in your
.vimrc for this particular example (other python syntax settings
include python_highlight_numbers, python_highlight_space_errors,
python_highlight_exceptions).

Use python_highlight_all to turn them all on.

To do it by hand and have it automatically come on in all .py buffers,
you could do:
au BufEnter *.py syntax keyword pythonFunction abs apply basestring
bool
au BufEnter *.py syntax keyword pythonFunction buffer callable chr

etc.  Put as many as you want on one line.  Use other syntax groups if
you want them highlighted as something other than functions.

Or, with vim's builtin python interpreter you could grab the list of
builtins directly, for instance have this in your vimrc:
pyf ~/.vim/vimrc.py

And have this in ~/.vim/vimrc.py:

import vim
# Might want to trim out exceptions/leading underscores/etc from
this...
builtins = ' '.join( [ b for b in dir(__builtins__)] )
vim.command('au BufEnter *.py syn keyword pythonFunction '+builtins)




More information about the Python-list mailing list