I have found that code-folding helps me organize my files better. Thus, at the bottom of my ~/.vimrc, I enable vim code folding by default:

""Folding
set foldmethod=indent
set foldnestmax=2
nnoremap <space> za
vnoremap <space> zf
"set nofoldenable       "set this to disable folding on file open

This has the advantages of using SPACE to toggle folds at the cursor, or if they start to annoy me I can use zR to unfold everything.

However, I'm also addicted to syntax highlighting. I use Dmitry Vasiliev's python.vim, but it doesn't highlight syntax in a fold line:

vim folded, no syntax highlighting

The lack of syntax highlighting for Field('id', type='integer', unique=True, notnull=True), makes it hard on my eyes when I'm used to seeing the highlight colors

What I'm looking for is a python.vim that supports syntax highlighting on a fold summary... if it Dmitry's did, it would highlight the strings in green something like this:

desired folding highlights

I want to continue using foldmethod=indent, if possible. Is there a way to get syntax highlights on fold summaries? Perhaps another python.vim?

有帮助吗?

解决方案

This question was asked previously and the answer was that it's not possible since the fold headline is not actually part of the file, thus never gets scanned by the highlighter. :(

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top