pythonvisual-studio-code

Disable auto wrap long line in Python code in VS Code


I use Visual Studio Code to write Python code with Pylint.

When I press Ctrl + S (save), the editor wraps a long line into multiple short lines. How do I disable the action or configure wrap column count to 120 (default is 80)?

I have tried "python.linting.pylintArgs": ["--max-line-length=120"] and "editor.wordWrapColumn": 120, but it didn't work.


Solution

  • Check your Python formatting provider.

    "python.formatting.provider": "autopep8"
    

    I guess in your case it is not Pylint which keeps wrapping the long lines, but autopep8. Try setting --max-line-length for autopep8 instead.

    "python.formatting.autopep8Args": [
        "--max-line-length=200"
    ]