microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
164.89k stars 29.52k forks source link

Disable autoindent #5446

Closed cfjedimaster closed 5 years ago

cfjedimaster commented 8 years ago

Currently there are multiple ways to configure indention, but no way to disable auto indention. For example, I enter <p>, hit the enter key, and on the next line the cursor has indented. I want to disable that.

alexdima commented 8 years ago

@cfjedimaster We have an open PR #5423 that would make it that pressing subsequent Enter, the inserted whitespace gets trimmed.

Also, are you finding this behaviour annoying in a certain programming language, or when doing something specific, most of the feedback we got so far is that indenting to the right spot is a helpful feature, and not an annoyance, so I'm wondering if you're hitting a use-case where this doesn't work as expected.

cfjedimaster commented 8 years ago

I'm finding it only an issue in HTML, maybe because I tend to have specific ways of indenting in HTML, specifically I keep head and body at the same level as html. #5423 doesn't look to be exactly what I want - I really just want no white space inserted at all. I hit enter, and my cursor will be at position 1 in the next line.

cfjedimaster commented 8 years ago

Another example - given form fields where I'm wrapping each label and input in a particular div, I like to have them all at the same indentation level.

Luminoth commented 8 years ago

I'd like to second this feature request. Right now not being able to turn that off is the only thing stopping me from using VSCode as my main editor.

maximecb commented 8 years ago

Would also like to be able to disable auto indent. I generally don't like automatic behaviors that try to guess what I want to do, because they often guess incorrectly.

peredin commented 8 years ago

Just like others have already mentioned this "feature" is quite annoying. I dislike any kind of automatic behavior that cannot be turned off. If I want to indent a line I will use the tab key manually.

ste2425 commented 8 years ago

Auto indenting is also quite annoying when working with projects that enforce the no-trailing-spaces rule of ESlint and others.

The auto indenting instantly fails this rule.

roman01la commented 8 years ago

I'm using Parinfer plugin to auto balance Clojure code. Auto indentation on Enter press doesn't allow Parinfer to place a cursor into inferred position.

Kobnar commented 7 years ago

There's the pretty obvious use case of editing raw text.

I understand vscode is a code editor, but it's pretty silly that I have to switch to a different application if I want to write normal text with typical, first-line indentation standards. Otherwise, I have to trip over an auto-indent feature that can't be turned off.

ajbogh commented 7 years ago

Any information on whether this feature was implemented, or maybe a workaround to disable auto-indentation? I'm working on a React project where the indentation gets confused when HTML is inserted into the js files, even though "Javascript React" is chosen as the file type. I'd rather disable auto-indentation and indent manually, or at least use same-level indents where the editor doesn't try to tab the next line in, instead it attempts to maintain the same level of indentation unless the user presses the tab key to indent further.

aclarkxyz commented 7 years ago

This certainly seems to be the IDE trend these days, but it is profoundly annoying: having really basic auto-indenting to the same column as the previous statement is great, but having the level jumping back & forth as you type, or presuming you want an extra one, is a pointless productivity killer. VSCode is a fantastic tool in general because it's lightweight and relatively simple - not cluttered up with a trillion features that think they know more about programming than you do - but we really need to be able to switch off some of the extra fancy stuff.

cfjedimaster commented 7 years ago

I'm confused -the last update supposedly adds indent stuff (https://code.visualstudio.com/updates/v1_14#_auto-indent-on-type-move-lines-and-paste) yet I still can't disable auto indent, even with editor.autoIndent:"false".

quanticle commented 7 years ago

editor.autoIndent controls whether the editor with indent or unindent based upon the indentation rules defined for the language. So, for example, you can define a rule for python that indents in on ":\n", and then out-dents on "return".

Setting editor.autoIndent to false disables that particular form of autoindentation, and then causes VSCode to revert to the older form of auto-indenting, where it keeps the next line at the previous line's level of indentation. It does not disable autoindentation entirely.

Personally, I think the flag is mis-named. I would have called it something like "editor.followIndentRules" or something similar rather than "editor.autoIndent".

cfjedimaster commented 7 years ago

For me, in HTML at least, it is auto-indenting. So it isn't staying at the same level. Either way - it sounds like it is a bad name as you say.

I find it a bit frustrating that other stuff was added in regards to indentation before being able to completely disable it.

codenamezjames commented 6 years ago

Is there a status on this??

auchenberg commented 6 years ago

Question on StackOverflow has passed 750 views. https://stackoverflow.com/questions/36664324/how-to-disable-autoindent-on-enter

Rhywun commented 6 years ago

I don't mind the behavior where pressing Enter keeps the next line at the previous line's level of indentation. But that should only happen the first time you press Enter. I can press Enter ten times and I get nine blank lines followed by a line indented at the level of the line ten lines up. That's madness. That sort of indentation is not useful in any language that I'm aware of. The second time you press Enter without typing anything, the cursor should be positioned at column one.

rcook commented 6 years ago

I think this behaviour is particularly problematic with programming languages like Python and Haskell where the autoindent often (nearly always) produces invalid or semantically different code.

mainakk commented 6 years ago

It is also problematic with Scheme (and Scheme-like languages). It doesn't let format code in the following way:

(define f
  (pp 1)
  )

It changes it to:

(define f
  (pp 1)
)
bertfw commented 6 years ago

It should be possible to disable this auto-indent feature entirely, meaning that when you hit Enter the cursor is positioned at column 1 on the next line. I'm hardwired to hit tab when I know I'll need an indent, so having the editor forcibly add an indent is infuriating. There are times when keeping the previous level of indentation could be a positive thing, but these are so far and few between that using select-block-tab is just as good, making auto-indent rather pointless.

In fact I'd even say that in general, the control of anything "autoformat" should be left to the end user.

aclarkxyz commented 6 years ago

There should really be 3 settings for autoindent:

I can't imagine anyone would feel left out if all of these were available as configuration choices. The default can be whatever is most popular.

thenexus00 commented 6 years ago

I am having this issue mainly with the CSS. Every time I add a new CSS line it starts indented instead of a new line. Here is just one example:

screenshot 2018-04-27 12 01 22

It actually gets pretty frustrating :(

ghost commented 6 years ago

From my understanding you are saying that every time you save VSCode is auto indenting? If it is auto indenting check all your braces to make sure they are closed. This problem occurred in a css file and after a quick debug I found out one of my braces was not closed causing my entire file to auto indent every time I saved. To help find unclosed brackets I recommend installing the extension " bracket pair colorizer ". Hope this helps.

thenexus00 commented 6 years ago

It is not to do with the code in terms of errors but rather the CSS format. VSCode right now only considers the designer style format and not other format conditions like single line Pico structure. I am even seeing similar issues with Flutter (Dart) as well during mobile apps and even if your doing standard formats.

On 24/7/18 9:24 am, andrewriveraj wrote:

From my understanding you are saying that every time you save VSCode is auto indenting? If it is auto indenting check all your braces to make sure they are closed. This problem occurred in a css file and after a quick debug I found out one of my braces was not closed causing my entire file to auto indent every time I saved. To help find unclosed brackets I recommend installing the extension " bracket pair colorizer ". Hope this helps.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/Microsoft/vscode/issues/5446#issuecomment-407231375, or mute the thread https://github.com/notifications/unsubscribe-auth/AEHOUJ33Rs6cZ6AZiaw2zAXoHRdyPHUEks5uJlsrgaJpZM4IJo-P.

bertfw commented 6 years ago

Hi Andrewriveraj, It doesn't have to do with save. Whenever hitting "Return" to create a new line it autoindents the new line even if all indenting options are disabled. This does not seem to be an issue on the Windows version, at least not in my experience - only OS X. I have not tried the Linux version.

ajbogh commented 6 years ago

I've come to the conclusion that prettier may be the solution to this problem. Instead of using VSCode's formatter, we should instead default to prettier.

https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode

With eslint you might use the eslint-prettier package following similar instructions as these:

https://medium.com/@sgroff04/configure-eslint-prettier-and-flow-in-vs-code-for-react-development-c9d95db07213

One particular place where I had trouble was with React development using Flowtype with the "Javascript React" layout preset. Typescript worked fine with the "Typescript React" preset but "Javascript React" broke after the first JSX code.

roman01la commented 6 years ago

Prettier is tied to supported languages and not necessary a tool that someone might want to use.

peredin commented 6 years ago

@ajbogh I fail to see how Prettier is even slightly related to the issue of auto-indentation not being disableable. Even if it wasn't "tied to supported languages" as mentioned earlier.

Prettier is used by some of the projects I work with and it is great for auto-formatting code, but it doesn't help me to not have new lines indented by default.

cfjedimaster commented 6 years ago

@peredin Thank you - it really feels like things are straying from the original request. :)

ajbogh commented 6 years ago

@peredin, it is a tool that helped me in some ways with the auto-indentation. You're absolutely right that it doesn't fix the underlying problem or solve cases where prettier cannot be used, but for those that it can be used it should be noted as an alternative. Hopefully the information that I provided can help someone.

thenexus00 commented 6 years ago

Hi, I had a mobile app deadline and got super busy. In terms of CSS here is a quick video I just made: http://recordit.co/ddjWLwyF7D I got several issues with the indenting as I mentioned but this shows how Even if you point to the start of a line and paste the auto indent kicks in when it really shouldn't. I am not sure the thinking of why. If I hit enter it starts in a place I think is OK but if I decide to point to the start and paste something, thats where I want it to go. For my CSS I prefer a Pico format of one line but there are about 4/5 most commonly used CSS formats either pure or then if using something like LESS.

Visual studio seem to try and help considering only one single CSS layout method.

Further to my issues - Building Flutter / Dart apps I am encountering the same problems. The standard practises and formats developers are looking to have here which I am trying to follow Visual studio starts to be very annoying with the auto indent predictions.

Basically there are few formats of code patterns for different languages and file types. Visual studio is trying to be smart and help you but is only considering a handful of methods for each.

DavidEGrayson commented 6 years ago

The auto-indentation in VSCode is really annoying when editing HTML, because it does not understand basic parts of HTML5 syntax, such as the fact that opening an <li> tag directly inside another <li> tag implicitly closes the earlier tag. Copying and pasting list elements inside such a list becomes a big chore because the auto-indentation screws everything up, and I have to press Shift+Tab a few times to unindent my selection after pasting.

It's kind of shocking there is no way to turn off this annoying and incomplete feature, except for clicking on "HTML" in the lower right corner, typing "plaintext", and pressing Enter. (And this workaround makes me lose syntax highlighting.)

aggieben commented 5 years ago

I sometimes find that VSCode gets in a state where it thinks it needs to indent the wrong number of spaces (say 8, instead of 4) based on some formatting somewhere in the file. I generally like autoindent, but it's maddening when it gets in this state. Using F♯ in my case.

wbrian-onlineed commented 5 years ago

I was enjoying being a new user of VSCode until today when i ran into this issue. Now it's just infuriating. I'm working on a codebase that has a quarter million lines using Ratliff indentation and i have to reverse VSCode's attempts to be helpful on each and every "}".

+1 on idea to have a "keep" indentation mode that just stays on the same line unless i say otherwise. My other text editor has this and it seems silly the VSCode does not.

Neonit commented 5 years ago

I was just about to start liking VS Code really much, but this basic feature is missing since 2016? What the hell, guys, are you serious about this?

nate-owens commented 5 years ago

I'd also love the ability to turn this off. I really love VS Code, but when I'm working in PHP and mixing HTML with PHP tags, the editor gets totally confused with its indentions.

kgfly commented 5 years ago

I just want a notepad/basic experience for no reason. Thanks.

The bug was filed 3 years ago. And still unresolved~~

frenchtoastbeer commented 5 years ago

Please!? Pretty please!? VSCode is regarded by me as best in class. Things work, and relatively straightforward, and that's great. One brief and relatively small install and I get a syntax highlighting editor with a console window that knows how to color all the syntax for all the languages I use.

What isn't great, is that I can't find all the damn buttons to turn off Microsoft's addiction to moving my cursor, closing my brackets, closing my strings, finishing my sentences, or offering suggestions to name my children.

I want to click one button labeled, "Don't pretend you know me." and forever afterward vscode simply accepts that we'll never be soulmates and stops trying to make our relationship more than it is.

Is this ever going to happen?

Please?

David263 commented 5 years ago

This long Issue, lasting about 3 years, is pitiful! I was evaluating VSCode to replace my great NoteTab Pro editor (which cannot handle Unicode), but this enforced automatic indent behavior, even for plain text files, is absolutely not acceptable. VSCode is otherwise so nearly complete and nearly what I want. But if its developers cannot respond to what users clearly feel is a bug, then the product is unusable. This Issue would move the heart of a stone, yet produces no fix. No way will I get dependent on using a product with such poor support.

redtide commented 5 years ago

Is Microsoft all the same that tries to make things in place of people thinking they are like idiot and do it also badly? This indentation thing is really bad and annoying and the worse thing that the best thing to do is so simple: doing nothing! Why I can't disable this shit?

David263 commented 5 years ago

redtide, as I indicated, this is the reason I rejected VSC as my new editor. So far I have evaluated 13 editors and none is as good as my current editor for my purposes, NoteTab Pro. Unfortunately, my editor cannot handle Unicode and is no longer maintained, so I have to move to another editor. Currently, I'm trying to find workarounds that will make UltraEdit acceptable for my purposes (working on many small projects and subprojects that don't use frameworks or libraries). VSC is great in many ways, but automatic indentation that cannot be disabled is an interruption of productivity with which I cannot live. I think you are right, Microsoft cannot see a bug when it's right in front of them.

redtide commented 5 years ago

@David263 indeed, I tried one time to try Atom, which VSCode is a fork of AFAIK but I was lost there and I missed some feature that I'm using, which are not so much but I need those. It's hard to accept to have a good tool and not able to use it because just one stupid funky useless and bad feature like this.

David263 commented 5 years ago

We cannot encourage a poor design by using it. Big companies have to learn not to be so arrogant. A useful design principle is "least astonishment".

aclarkxyz commented 5 years ago

Hey guys, maybe a little bit less hating on this thread? First of all, VSCode is doing a really good job of honouring open source principles - it's totally free, actively maintained at great expense to someone else, and with the exception of the occasional glitch, it's really good. Regarding the auto-indenting: there were a few releases in which it was incredibly annoying and broken, and I had to hard-patch some of the code each time it updated itself. But now if you switch off the 'Auto Indent' flag in the settings, most of the really intrusive behaviour stops. It's not precisely what I'd like, but it's close enough to silence my complaints.

redtide commented 5 years ago

But now if you switch off the 'Auto Indent' flag in the settings, most of the really intrusive behaviour stops.

@aclarkxyz What version is that? Here it doesn't change at all.

Versione: 1.40.1 Commit: 8795a9889db74563ddd43eb0a897a2384129a619 Data: 2019-11-15T22:58:14.270Z

David263 commented 5 years ago

Alex, I apologize for the hating. It's just that it is so frustrating when any software (open source or not) is not fixed after a period of many years of complaints. I appreciate the fixes you have done, but turning off the auto indent option was the first thing I did the day I began to evaluate VSC. You may have fewer complaints, but there are many times that I pressed Enter during my testing and the caret did not go to the beginning of the next line as expected. At first, this astonished me. After a few times, it annoyed me. Why? Because it's a bug, and because it was reported years ago. Yes, it may be true that the worst of the intrusive behavior no longer happens (I never saw the really bad behavior, I guess), but it happens enough that I cannot adopt VSC as my new editor. You should care about this, and help get the VSC developers to fix the bug completely. Bugs should not survive one month, never mind several years, in my opinion. In my 40 year software career I always fixed bugs assigned to me completely and quickly. It is my experience that bug fixing is either a lost art or people don't care anymore, for few products these days are supported the way they should be, open source or not.

redtide commented 5 years ago

Well it's really stupid to set by default something instead let people set if needed, it's their usual behavior, the same reason I stopped using windows. I was kinda unsure to install their product on my system and for a while was OK, I have endured this indentation behavior too much long and now I need to switch back to the previous editor and loose time to set it up from scratch as this configuration. There is also my time and trust, not only their benevolence to share freely their s...oftware.

Neonit commented 5 years ago

From my personal experience I can now say that it is an exaggeration to say my productivity is constantly be lowered by this. I got used to it quite quickly. The problem is, however, that I don't want to get used to auto-indentation. It's not a time-saver in any way for me.

I can fully understand the rage about this topic as well, because I for my part just am not able to understand why this is such a big deal that stays open for over three years (and this makes me frustrated).

Where are the devs, who know the auto-indentation/-completion system inside-out (or at least better than the average user) and either could easily change this in minutes or could at least explain, why it is difficult or not possible, maybe contribute their knowledge at least so someone with way less insights (e.g. me) could get a starting point to have a look on their own.

I hope this is not being ignored, because having it as a force-enabled feature is some religious thing by the devs.

aclarkxyz commented 5 years ago

But now if you switch off the 'Auto Indent' flag in the settings, most of the really intrusive behaviour stops.

@aclarkxyz What version is that? Here it doesn't change at all.

Versione: 1.40.1 Commit: 8795a98 Data: 2019-11-15T22:58:14.270Z

Two issues, I think. Now and at all times in the past, it will add an extra indent level for you under certain circumstances. Personally I do not like this (and that's the opinion of everyone else on the thread too), but I have made my peace with it: I have so few other complaints that I can learn to live with this relatively minor nuisance. And since almost every other modern editor is so much worse, I figured I'd just call this a win.

The other issue is that there were several releases where it was severely broken for anyone who doesn't use one of the wretched misaligned-brace styles: it would guess your indent level (wrongly), and then adjust it to something else as soon as you typed a character. It was totally unusable, and the only solution was to hack some of the source files after each release. This did eventually get fixed. If this sort of thing happened on a regular basis, I'd be full of rage, too... but fortunately it doesn't!

David263 commented 5 years ago

Alex, I think you are remarkably, amazingly tolerant. I'm not. My software tools must work, they must work well, they must further my productivity, and they must not cause repeated frustration. If they do, I report bugs. If the organization that supports a tool does not believe in fixing bugs unless they are so extreme that the tool cannot be used, I abandon the tool and the organization, not because I want to but because I must.

In the case of editors and browsers, for some reason (as opposed, say, to javascript frameworks or string conversion tools), organizations appear to tolerate bug reports of many years' duration. This is well beyond my understanding: computers are supposed to make our life more fun, not give us frustration, and developers are supposed to fix bugs, not rationalize their continued existence. VSC is supposed to be a new product, yet it acts like a product bent over with rheumatism, hobbling around like an old man (I'm 73 years old and I can still find and fix bugs).

You and I live in different worlds so far as our philosophy of software tool maintenance is concerned. That would be fine if the stakes were not quite so high. But I will not compromise on software tool usability. Life is too short to live in frustration.

Although it is true that few of the software tools I have created have had any bugs, I have always fixed my own bugs quickly (I posted that already; you may have noticed). Why can't others fix their bugs as well as I did throughout my 40 year career? Is it laziness, or the fact that these developers leave too many bugs behind, or write unmaintainable code? There has to be a reason.

In the software industry, we implement in stages. We first create a design specification and review it, so problems can be caught early, where they are easier to fix. Then we unit test and do code reviews (I'm abbreviating) so coding bugs can also be caught early, where they are easier to fix.

I see no reason why using an Open Source approach to collaboration has to produce many unresolved bugs, or has to result in justifying the continued existence of bugs years after they have been reported.

There is something broken about how VSC was created and/or is now supported.

I'm not filled with hate, as you first supposed, and I hope you appreciate that I am presenting balanced opinions, not incivilities or anger. I'm simply explaining that something is wrong with VSC support and that I cannot adopt VSC in spite of its many reliable and well-thought-out and well implemented features.

There is just no excuse for not fixing bugs (defined as receiving bug reports from various users), especially the amazing excuse that the feature used to have an even worse bug that was fixed.