4 ms·
Every time I try to use Visual Studio as just a text editor I find its behaviour of spaces/tabs a complete disaster. I know that heaps of people use it and love
by TheNewAndy 5y ago
Every time I try to use Visual Studio as just a text editor I find its behaviour of spaces/tabs a complete disaster. I know that heaps of people use it and love it, so I can tell that it must be me that is the weirdo, but is it too much to ask for:
1) Pressing tab inserts a tab
2) Pressing space inserts a space
3) Pressing enter inserts a newline, with the new line starting with the same whitespace as the previous line
4) Pressing shift-tab removes the leading tab from the start of the current line, or N(=4) spaces from the start of the current line
No surprises, no auto-formatting, no having to go and reconfigure your text editor behaviour when you find random files with different conventions, no modelines etc. I see the huge depth of preferences in VS, and think it must be possible, but every time I come away less confident.
- will4274 5y agoNo, it's not too much to ask for, and visual studio supports that. But, it is too much to ask for as a default, because it's a terrible choice. The only reason somebody would want both #1 and #2 is if they put tabs and spaces into the same document. That's a terrible idea. Also #3 - why wouldn't I want my editor to auto indent the next line after an opening brace? I'm sorry, but the visual studio defaults are just better (and more popular) than your choices.
- TheNewAndy 5y agoObviously the defaults are going to be more popular than my non-default preference, and I would even agree that if there was no default, and people were forced to choose, they mostly wouldn't choose what I want. However, if you can tell me how to get visual studio to do this, then I would be incredibly grateful. In my opinion mixing spaces and tabs is completely fine because they are for different things. Tabs for indentation, and spaces for alignment. Why no auto indent? Because the editor doesn't have enough information to do it correctly (e.g. perhaps you are about to paste some code which is already indented as you want it). I am not saying you should have the same preferences as me, but I am pretty happy with this behaviour, and perfectly ok with pressing tab after enter (or even pressing space 4 times - again, this is just my personal preference and I know that there was a time in my life when I would have looked at this with disgust). So - how do I configure VS to do what I want?
- jayd16 5y agoJust google "visual studio disable auto format." The first hit most likely provides exactly what you want. https://stackoverflow.com/questions/737222/turn-off-auto-formatting-in-visual-studio https://stackoverflow.com/questions/737222/turn-off-auto-for... You won't get much more help unless you describe what you've tried and why it didn't work for you. As far as I can tell the settings you're looking for aren't very hidden.
- TheNewAndy 5y agoWhen I tried last time (sorry, I don't have visual studio in front of me), I would get things like: - Pressing enter results in just adding a newline, without copying the whitespace from the previous line OR - Pressing enter results in addine a newline, copying the whitespace, but replacing spaces with tabs on the new line I guess if someone could once show how to make it so adding a newline to: <tab><space><space><space><space>foo (when configured with 4 space tabs) I get: <tab><space><space><space><space>foo <tab><space><space><space><space> Instead of: <tab><space><space><space><space>foo <tab><tab>
- tracker1 5y agoDrop an appropriate .editorconfig file in the root of your solution. IIRC that will cover most of what you want to do. As to the format on paste.. you can explore the settings. Generally speaking, I have VS Code configured how I want it and will use that over 95% of the time... even for C# projects.
- AnonHP 5y ago> The only reason somebody would want both #1 and #2 is if they put tabs and spaces into the same document. That's a terrible idea. I’m not sure if the GP is asking for what you seem to be referring to. I thought of that request as the keys should insert the characters they stand for. Are you thinking only about multiple spaces used instead of a tab? Spaces are routinely used to increase readability in code. Even something as simple as comparisons in loops are more readable with spaces around the symbols. There are many other cases where spaces are used as spaces.
- TheNewAndy 5y agoI think they understood. I'm happy with this as an example of a mix (and now prepared for the formatting to be eaten), which I believe would be seen as obscene by the commenter: { <tab>foo(arg1 <tab> ,arg2 <tab> ); } Though I think this example is less likely to be controversial: { <tab>bar(); /* Some comment <tab> * across two lines */ } But it is all fine, because I don't really feel like I need to defend my preferences - that is the nice thing about them.
- merb 5y ago#3 is stupid if it keeps inserting whitespace if you use git, its a horrible experience.