Skip to content

Options for automatic indentation #19303

Closed

Description

Automatic indentation currently coming out of the box with VSCode is really unhelpful in any white-space significant programming language.

Twitter discussion (F#): https://twitter.com/isaac_abraham/status/824035064807731201
Problem reported in Python plugin: https://github.com/DonJayamanne/pythonVSCode/issues/666
Example behavior in F# (notice how new errors are shown after this automatic formatting):
ident

As far as I understand this behavior can be controlled using IndentationRules in LanguageConfiguration but:

  1. They are RegEx based which won't allow us to create accurate behavior.
  2. Default behaviour is completely wrong on any white-space significant language.

I think it would be good to add option to disable this behavior.

Activity

  1. isaacabraham commented on Jan 24, 2017

    @isaacabraham

    "good option", more like "must have". This is driving me crazy.

  2. forki commented on Jan 25, 2017

    @forki

    brackets

  3. mousetraps commented on Jan 25, 2017

    @mousetraps
    Contributor

    Oh no! Looks frustrating - sorry about that! Peng Lyu (@rebornix) and alexandrudima to the rescue!

  4. added
    bug
    on Jan 25, 2017
  5. alexdima commented on Jan 25, 2017

    @alexdima
    Member

    Fixed via b1c8dad

  6. forki commented on Jan 25, 2017

    @forki

    wait a second. Did you add a fix for the concrete issues or did you allow us to disable it completely? Because I think we really need the second one.

  7. alexdima commented on Jan 25, 2017

    @alexdima
    Member

    That fix targets a different issue similar in nature, and the fix is that typing a closing bracket will not change the current line's indentation if the bracket is preceded by any non-whitespace characters, covering both issues exemplified in the two gifs in this thread.

    Tomorrow's insiders build will contain the change and it would be great if you could try it out and provide additional feedback. We can then proceed to reopen this issue or start a new one, as you prefer.

  8. isaacabraham commented on Jan 25, 2017

    @isaacabraham

    alexandrudima I really think having the ability to turn the auto-format off is important. Not everyone wants it.

  9. forki commented on Jan 25, 2017

    @forki
  10. forki commented on Jan 25, 2017

    @forki

    brackets

    there are millions of new edge cases to find...

  11. 7 remaining items

  12. isaacabraham commented on Jan 26, 2017

    @isaacabraham

    Here's one.
    test

  13. isaacabraham commented on Jan 26, 2017

    @isaacabraham

    Another similar one: -
    test

  14. isaacabraham commented on Jan 26, 2017

    @isaacabraham

    I can confirm that some of the other cases that I see on the mainline build are fixed on the insider build. But I still think you should allow people to turn this off - people might use a formatting style you don't cater for, or simply not want it at all.

  15. gandhis1 commented on Jan 27, 2017

    @gandhis1

    Let me know if this is unrelated, but I see a similar issue with Python as I reported in https://github.com/DonJayamanne/pythonVSCode/issues/666

    image

    Edit: Just realized this was already referenced by OP.

  16. forki commented on Jan 27, 2017

    @forki
  17. gandhis1 commented on Jan 27, 2017

    @gandhis1

    I tested this on the latest insider, and it appeared to be fixed.

    Although my question would be now, is when you have an open bracket expression that has yet to be closed, and you press enter, why the default behavior is not to indent to the parenthesis location.

  18. peredin commented on May 22, 2017

    @peredin

    I definitely want to be able to disable any automatic indentation completely.

    As it is now, if I'm at the end of a line <tab><tab>void foo(); and press enter VScode will automatically add <tab><tab> to the next line which for me is anything but helpful.

    Tested in both the latest Insiders build and 1.12.2.

  19. added
    editor-autoindent
    on Jun 7, 2017
  20. rebornix commented on Nov 3, 2020

    @rebornix
    Contributor

    editor.autoIndent setting is now enriched to allow you disable this feature completely.

  21. locked and limited conversation to collaborators on Dec 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

editor-autoindentfeature-request

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions