(Move categories to tip template) |
(Adjust previous/next navigation) |
||
Line 2: | Line 2: | ||
{{TipImported |
{{TipImported |
||
|id=741 |
|id=741 |
||
− | |previous= |
+ | |previous=739 |
|next=742 |
|next=742 |
||
|created=June 7, 2004 |
|created=June 7, 2004 |
Revision as of 03:10, 30 June 2008
Tip 741 Printable Monobook Previous Next
created June 7, 2004 · complexity intermediate · author Lee Chun Kin · version 6.0
With the folding function of Vim6 (+folding), we can edit the Python programs similar to outline program editors such as SciTE.
Add the following lines to vimrc:
augroup python_prog au! fun! Python_fold() execute 'syntax clear pythonStatement' execute 'syntax keyword pythonStatement break continue del' execute 'syntax keyword pythonStatement except exec finally' execute 'syntax keyword pythonStatement pass print raise' execute 'syntax keyword pythonStatement return try' execute 'syntax keyword pythonStatement global assert' execute 'syntax keyword pythonStatement lambda yield' execute 'syntax match pythonStatement /\<def\>/ nextgroup=pythonFunction skipwhite' execute 'syntax match pythonStatement /\<class\>/ nextgroup=pythonFunction skipwhite' execute 'syntax region pythonFold start="^\z(\s*\)\%(class\|def\)" end="^\%(\n*\z1\s\)\@!" transparent fold' execute 'syntax sync minlines=2000 maxlines=4000' set autoindent set foldmethod=syntax " set foldopen=all foldclose=all set foldtext=substitute(getline(v:foldstart),'\\t','\ \ \ \ ','g') set fillchars=vert:\|,fold:\ set tabstop=4 shiftwidth=4 nowrap guioptions+=b endfun autocmd FileType python call Python_fold() augroup END
You can use the folding functions (zm, zM, zr, zR, xa, zo, zc, zx...) in editing Python programs.
Comments
Or you could use the python_fold script (script#515).