0

my .vimrc shows vertical lines so i can follow identation blocks easily, like pretty much every single text editor/IDE.

if(x == 1){
|   if( y == 1){
|   |   y();
|   }
}

is there any way i can make this more useful and show the identation level instead? I won't mistake it for actual code since i already use an extremely-low contrast color for those.

if(x == 1){
1   if( y == 1){
1   2   y();
1   }
}

That would be really helpful to find my nesting level in some crazy methods i have to refactor on my job. My current work-around involve having a horizontal windows just so i can leave the top one when the blocks start to get crazy and the bottom one where i navigate to change code.

PS: i already have rainbow parenthesis plugins. but those are not helping anymore.

1
  • 1
    Not that I know of, but there are tons of vim plugins out there so there might be something. If you don't get an answer here, you might try asking here.
    – blm
    Commented Dec 10, 2015 at 18:12

2 Answers 2

0

I don't have enough rep to comment on your question, so I'm posting an answer instead and will update it if I can find something better. Here's my "answer":

It's not exactly what you're asking for, but have you tried ":set list" yet? (":set nolist" to deactivate). If they are hard tabs (true tab characters, e.g. ^I), this will show a ^I for each tab. That way, you can both visually see and count the number of tabs for any given line. That's why I say it's not exactly what you're looking for, e.g. the format you supplied/suggested in your question.

Also, FWIW, I also was in the habit of using
if(statement){
// code here...
}

when working with less complex code (e.g. hundreds of LOC, and at most a few files). Once I started working on projects with thousands to millions of LOC and hundreds of files, I began using
if ( (complexStatement) )
{
// code here...
}

so the brackets would line up (a little bit of the same idea you're after, IMO). This really helps when you also use % to swing between brackets in vim. I also use the horizontal window split, as some code is just too long sometimes (begging for its own function, etc.).

HTH

1
  • You could reference this post. The unaccepted answer points the OP to :help listchars. In the docs, looks like you can set your own style for tab displays, e.g. >--- instead of ^I. Maybe try that? No plugins required.
    – tniles
    Commented Dec 10, 2015 at 18:45
0

Well, it doesn't do exactly what you want, because this is not possible. But you can use my DynamicSigns plugin to display the indentation level in the gutter column. Set :let g:Signs_IndentationLevel=1 and run :Signs.

See the help at :h DynamicSigns.txt for what you can do with it.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .