pythonvisual-studio-codeauto-indent

Where is the vscode setting governing this weird extra-space newline indentation when you have a closing bracket on the line?


I've been using VScode for a while - and have been experiencing a weird extra space recently (anecdotally since I've upgraded to the most recent version).

So, this happens when editing python if there is a closing bracket and I hit enter to move text to the next line:

  1. The text will go to the correct place based the indentation guide settings
  2. pause for a second to laugh at me
  3. Then add an extra space.

This doesn't happen if there isn't a closing bracket, but is annoying because the closing bracket is auto-added when I put in the opening bracket, and so this happens way more often than it should.

So, I start with this:

def function():
    cases = pq.read_table(
        "filename.parquet",
        columns = ["docket_number"]

Press enter, and then I get (dots are spaces, but added to highlight the issue):

def function():
    cases = pq.read_table(
        "filename.parquet",
        columns = [
        ....."docket_number"]

And the indent should be 4. If there wasn't a closing bracket, it correctly give me this:

def function():
    cases = pq.read_table(
        "filename.parquet",
        columns = [
        ...."docket_number"

So, what the heck governs this?


Solution

  • You probably have editor.formatOnType enabled, turn it off (untick it),

    enter image description here

    or add the following in settings.json

        "editor.formatOnType": false,