VS Code changes indention of current line
See original GitHub issueI am using VS Code 1.28.2 on Windows 10. I’m editing an HTML file indented with tabs. But I have HTML <pre>
sections which I want indented with spaces.
Let’s say I have the following code:
<pre>
foo //I press <Enter> at the end of this line
</pre>
- When I open the file VS Code detects I use tabs. Fine.
- When I hit
<Enter>
at the end of the line that says “foo”, VS Code indents the next line. Fine. - VS Code isn’t smart enough to realize that I want to indent the next line with spaces instead of a tab, because it already got into its head that I want to use tabs everywhere. It’s not smart enough to realize that the previous line
foo
was indented with spaces. It uses a tab for the next line. But OK, I can live with that, too. It’s understandable. - Bug: What isn’t acceptable is that VS Code changes the indention of the existing line from spaces to tabs!!
Yes, when I hit <Enter>
after “foo”, it not only indents the next line but changes the indention that comes before foo
from spaces to tabs.
<pre>
foo //bug: the two spaces have been converted to a tab!
//this new line also has a tab, which I don't want but can accept for now
</pre>
VS Code has no business of changing the existing line. I simply hit <Enter>
to go to the next time. This is a huge problem, and it has likely corrupted a bunch of lines in this file because I didn’t catch on to what it was doing.
Sure, we have auto-indent features to try to automatically insert indent on the following line, but please don’t mess with the line I already have.
How can I turn this off?
Issue Analytics
- State:
- Created 5 years ago
- Comments:7 (1 by maintainers)
Top Results From Across the Web
VS Code tips — Indentation settings and the ... - YouTube
VS Code shows the indentation settings for the current in the status bar. Click on this entry to quickly change the tab size...
Read more >Basic Editing in Visual Studio Code
Learn about the basic editing features of Visual Studio Code. Search, multiple selection, code formatting.
Read more >Indentation style | JetBrains Rider Documentation
To manually increase or decrease indentation of the current line or selected code block, press Tab / Shift+Tab . To fix indentation of...
Read more >VSCode Keyboard Shortcuts / VS Code Key Bindings
Select a line, multiple lines or a block of code delimited by curly brackets that you want to indent. Now you can indent...
Read more >How to automatically indent your code in Visual Studio Code
Once enabled in the configuration, the auto-indentation feature will automatically indent your code whenever you type, move lines or paste ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
(Experimental duplicate detection) Thanks for submitting this issue. Please also check if it is already covered by an existing one, like:
Please clarify the exact steps to do this? Please see also issue #109382 I tried setting the value to ‘none’ under workspace settings, restarted vs code and and it does not work (on pressing Ctrl+S (save shortcut?) the indentation is corrected, which is not what I expect). (If #109382 is a separate issue, please reopen it).