Alternate indentation display in Vim

I came across this question: https://softwareengineering.stackexchange.com/questions/87077/how-can-a-code-editor-effectively-hint-at-code-nesting-level-without-using-inde and thought that Vim could do something similar with the plugin.

I believe that the level of indentation can be indicated by a sign (icon in the graphical interface, text with highlighting in terms). The part I'm not sure about displays indented lines. Does anyone know if and / or how you can do this?

This question is not whether it is desirable to display indentation levels in this way; but how to do it in Vim.

+6
source share
2 answers

You can use the conceal function, which is new in 7.3.

Here is a function that does something roughly what the article describes (for spaces, tab counting will instead be a pretty trivial addition):

 function! IndentationHeatMap() set conceallevel=1 for i in range(1,9) let indentation = repeat(" ", &sts * i) exe 'syntax match NonText "^' . indentation . '" conceal cchar=' . i endfor endfunction 

A solution close to what you are requesting can use conceal to hide all leading spaces with

syntax match NonText "^\s\+" conceal

and then use signs to provide indicators based on custom calculations.

Note: NonText in these syntax commands is an arbitrary selection group.

+3
source

Take a look at these plugins: Retreat Guide and IndentHL Both have screenshots.

0
source

Source: https://habr.com/ru/post/891574/


All Articles