Small but infuriating undesired auto-indentation in C++ source files
See original GitHub issue- VSCode Version: Code 1.15.1 (41abd21afdf7424c89319ee7cb0445cc6f376959, 2017-08-16T18:05:38.342Z)
- OS Version: Windows_NT ia32 10.0.14393
- Extensions:
Extension | Author (truncated) | Version |
---|---|---|
Bookmarks | ale | 0.16.0 |
githistory | don | 0.2.3 |
xml | Dot | 1.9.2 |
cpptools | ms- | 0.13.1 |
Steps to Reproduce:
Here’s a small snippet, where ^ is the cursor position (not an actual character in the file!)
{
if(x)
foo();
}^
If I press ENTER, the closing bracket and the cursor are auto-indented:
{
if(x)
foo();
}
^
This is a small but extremely distracting issue in code bases which don’t use brackets for single sub-statements.
Btw, “editor.autoIndent” is set to false
Reproduces without extensions: Yes/No - Yes
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:27 (11 by maintainers)
Top Results From Across the Web
Indenting C Programs
If you used a poor indentation style, you will probably have trouble following the logic of the code. And it's your own code!...
Read more >How do I make Emacs auto-indent my C code? - Stack Overflow
I set the return key to globally act as a new-line-and-intent in my ~/.emacs file: (global-set-key "\C-m" 'newline-and-indent).
Read more >Copy with proper indentation - Visual Studio Blog
You want to share some code you've written with a colleague, so you select it in the editor and hit Ctrl + C...
Read more >SMIE - Auto-indentation with incomplete information - arXiv
that they invariably only handle correctly a small subset of the language's syntax, but their main problem is the code's complexity and ......
Read more >Disable auto-indent of properties … | Apple Developer Forums
Problem is that it now auto-indent my Objective C class properties and ... way of doing things, and a lot of example code...
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
Not sure if this is the right place to post this, but I’m also having an issue with indentation in C++ source files. I’m not using the VSCode C++ extension so I’m assuming this behaviour is coming from stock VSCode.
When writing a function definition, after writing the opening brace (vscode automatically inserts the closing brace) and pressing Enter, vscode indents the next line and closing brace way too far. I’ve not found a setting to disable this. Setting
autoIndent
to false does not change the behaviour.Example:
Before:
After pressing Enter:
Desired:
Please see also #164177.