Python code block allocation in vim

I wanted to highlight the different levels of indentation in vim so that I could more easily identify large blocks of code. I have some reasonable large blocks nested for / while / with / try, and it's hard for you to identify a a in block, i.e. How many β€œtabs” do I have in front of the cursor.

Is there a way to highlight tabs?

Here is what I mean:

try: * while True: * * for foo in bar: * * * do() * if something: * * done() except bla: * exit() 

Where * will be a special background color.

I would also decide in some other way to identify the indentation levels.

+8
python vim syntax-highlighting
source share
2 answers

You can use the listchars options to display special characters (see :help listchars ).

For example, if you want to show tabs, you can use:

 :set listchars=tab:*\ " Be careful : there is a space after the backslash :set list 

You can also change the highlight colors using the highlight property of the SpecialKey group.

If you use vim in terminal:

 :highlight SpecialKey ctermfg=Cyan 

See :help highlight details.

You can also check :runtime syntax/colortest.vim to see all available colors.

+3
source share

All Articles