在 vim 折叠线中语法高亮 Python
我发现代码折叠可以帮助我更好地组织文件。因此,在我的 ~/.vimrc
的底部,我启用 vim默认情况下代码折叠:
""Folding
set foldmethod=indent
set foldnestmax=2
nnoremap <space> za
vnoremap <space> zf
"set nofoldenable "set this to disable folding on file open
这具有使用 SPACE 在光标处切换折叠的优点,或者如果它们开始惹恼我,我可以使用zR 展开一切。
然而,我也沉迷于语法突出显示。我使用 Dmitry Vasiliev 的 python.vim
,但它不会突出显示折叠行中的语法:
缺少语法 时,突出显示 Field('id', type='integer', unique=True, notnull=True),
让我的眼睛感到困难
当我习惯看到突出显示颜色 寻找的是一个支持折叠摘要语法突出显示的 python.vim
...如果 Dmitry 这样做了,它会以绿色突出显示字符串,如下所示:
如果可能的话,我想继续使用 foldmethod=indent
。有没有办法在折叠摘要上获取语法突出显示?也许另一个python.vim
?
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
?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(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. :(