在 vim 中高亮显示 python 代码块
我想在 vim 中突出显示不同的缩进级别,这样我就可以更轻松地识别大块代码。我有一些合理的大型嵌套 for/while/with/try 块,并且很难识别 a am 进入的块,即光标之前有多少个“选项卡”。
有没有办法突出显示选项卡?
这就是我的想法:
try:
* while True:
* * for foo in bar:
* * * do()
* if something:
* * done()
except bla:
* exit()
其中 * 是特殊的背景颜色。
我还愿意采用任何其他方式来确定压痕级别。
I wanted to highlight different indentation levels in vim, so I could identify large blocks of code more easily. I have some reasonable large nested for/while/with/try blocks and it gets hard to identify the block a am into, i.e. how many 'tabs' I have before the cursor.
Is there a way to highlight tabs?
This is what I have in mind:
try:
* while True:
* * for foo in bar:
* * * do()
* if something:
* * done()
except bla:
* exit()
Where * would be a special background color.
I would also settle for any other way to identify the indentation levels.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Indent Guides vim 插件正是做这种突出显示的。我将它与 listchars 选项一起使用(正如阿卡指出的那样)。
The Indent Guides vim plug-in does exactly this kind of highlighting. I use it together with the
listchars
option (as Ackar pointed out).您可以使用
listchars
选项来显示特定字符(请参阅:help listchars
)。例如,如果您想显示选项卡,可以使用:
您还可以使用
SpecialKey
组的highlight
属性更改突出显示颜色。如果您在终端中使用 vim :
请参阅
:helphighlight
了解更多信息。您还可以检查
:runtime syntax/colortest.vim
以查看所有可用的颜色。You can use the
listchars
options to display specifics characters (see:help listchars
).For example if you want to show tabs you could use :
You can also change the highlighting colors using the
highlight
property for theSpecialKey
group.If you use vim in a terminal :
See
:help highlight
for more informations.You can also check
:runtime syntax/colortest.vim
to see all the available colors.