question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Indent/Outdent with tab key does not honor editor.autoIndent=false

See original GitHub issue

Issue Type: Bug

When I have:

    /*
     * Comment
     */

If I select it and hit tab, I get:

        /*
        * Comment
        */

If instead I had hit shift-tab, I get:

/*
    * Comment
    */

Same happens with Ctrl-] and Ctrl-[ (if those are supposed to make a difference)

I hoped turning off autoIndent would stop this, but no dice. I also turned off C++ formatting in the JSON config:

{
    "editor.autoIndent": false,
    "editor.detectIndentation": false,
    "C_Cpp.formatting": "Disabled"
}

I have done due diligence by asking (and bountying, +100) a question on StackOverflow to get an answer on what to do about this, but no one seems to know:

https://stackoverflow.com/q/53326134/preserve-spacing-on-indent-or-outdent-with-tab-in-vscode

If someone can provide a resolution here, be sure to go there and get the bounty points.

VS Code version: Code 1.29.1 (bc24f98b5f70467bc689abf41cc5550ca637088e, 2018-11-15T19:13:36.375Z) OS version: Windows_NT x64 10.0.17134

System Info
Item Value
CPUs Intel® Core™ i7-7700HQ CPU @ 2.80GHz (8 x 2808)
GPU Status 2d_canvas: enabled
checker_imaging: disabled_off
flash_3d: enabled
flash_stage3d: enabled
flash_stage3d_baseline: enabled
gpu_compositing: enabled
multiple_raster_threads: enabled_on
native_gpu_memory_buffers: disabled_software
rasterization: enabled
video_decode: enabled
video_encode: enabled
webgl: enabled
webgl2: enabled
Memory (System) 15.86GB (1.40GB free)
Process Argv
Screen Reader no
VM 0%
Extensions (3)
Extension Author (truncated) Version
vscode-github Kni 0.30.0
python ms- 2018.10.1
cpptools ms- 0.20.1

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:11
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

4reactions
wasuajecommented, May 14, 2020

Guys Any update on this? I’m having the same issue!

1reaction
anchanncommented, Mar 5, 2021

This issue also affects indentation of XML severely. For example, with indentation set at 4 spaces, starting with this text:

<Component
 class='something'
 SomeProp='blah'/>

increasing indentation by one step using the “Indent Line” command produces this:

    <Component
    class='something'
    SomeProp='blah'/>

Starting with this text

    <Component
     class='something'
     SomeProp='blah'/>

and decreasing indentation by one step using the “Outdent Line” command produces this:

<Component
    class='something'
    SomeProp='blah'/>

This style of indentation may feel strange to some people, but that’s part of the whole issue — who are people, and who is VSCode, to tell others how to format their code? If I wanted my text editor to mangle my formatting, I would opt in to automated formatting.

Increasing and decreasing indentation should be a simple operation of adding or removing one fixed string (in my example, a string consisting of four spaces) to/from the beginning of each line. Yes, there are some important edge cases to take care of (e.g. what happens when one of the selected lines doesn’t have enough whitespace to take away on an outdent; or e.g. ignoring the last empty line of a block of lines selection), but VSCode gets them right already (and most plugins that implement things naively do not). Why confound the simple, deterministic operation of changing the indentation level with something as complex (and often buggy, which is why people turn it off) automatic formatting?

If changing the default behaviour of these actions is somehow controversial, can you at least provide “Indent Line Trivially” and “Outdent Line Trivially” pair of actions that people who don’t want their code mangled can use?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Visual Studio Code: format is not using indent settings
If it is the case, then just open Command Palette, type "Formatter" and select Formatter Config . Then edit the value of "indent_size"...
Read more >
Tab key in Microsoft Word does not increase indent in bullet lists
To fix this, click the Microsoft Office button, select Word Options . Under Proofing , click AutoCorrect Options... . Under AutoFormat As You...
Read more >
Word: Indents and Tabs - GCFGlobal
In Word indents and tabs add structure to documents. Use the MS Word indent ruler and tabs to help make documents clearer.
Read more >
Developers Who Use Spaces Make More Money Than Those ...
The advantage of a tab is that it allows you to choose your visible indent size. However, varying indent size makes it functionally...
Read more >
Tabs and indents settings does not work
Make sure that whole file uses correct indents (select all text and choose "Edit | Convert Indents"); Save and Close file; Ensure that...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found