Syntax-highlight Python in a vim fold line

a 夏天 提交于 2019-12-03 17:11:47

问题


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:

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:

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


回答1:


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. :(



来源:https://stackoverflow.com/questions/8655799/syntax-highlight-python-in-a-vim-fold-line

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!