tweekmonster / braceless.vim

:snake: Text objects, folding, and more for Python and other indented languages.
395 stars 13 forks source link

Somewhat intelligent auto-indent - is it possible to turn it off? #13

Closed for-coursera closed 8 years ago

for-coursera commented 8 years ago

Auto indent is based on recognized blocks instead of simply using the previous line's indent level. If you enter two blank lines, you'll drop back a level.

Don't know, if it's just me, but right now if you press an Enter on a zero-indented line, you got an indent on the next one. As I understand from the description, that seems to be a feat. Then, is it possible to turn it off?

tweekmonster commented 8 years ago

@for-coursera It's not just you. Changed it so that if you're more than 2 lines away from a non-blank line, it'll go with your indentation. I also made the auto indent slightly more intelligent:

if True:
    if True:
        pass
    else:
        pass  # press enter here
        elif:  # typing this and pressing : the autoindent
               # will trigger and move this back to column 1

If you still don't want to use the autoindent in this plugin, don't add the +indent to the BracelessEnable command. You will have to reload the buffer (:e! after :w) for it to take effect.

for-coursera commented 8 years ago

Thanks! That looks interesting...

Also, I somewhat was under impression that without +indent the objects themselves won't work, too. Good to know it's not true.

tweekmonster commented 8 years ago

I guess I should clarify the above example. The autoindent is contextual now. It'll know that the immediate if statement is already terminated with an else statement, and will indent the elif with the one above it. It does this for else, elif, except, and finally since those can be nested and are aggravating to properly indent when I want to keep typing.