Search code examples
pythonvisual-studio-codepep8

How to remove the line breaks that Visual Studio Code includes when saving the code


How to remove the line breaks that's added in the formatting when saving the code in VSCode

For example:

If I have an expression with multiple validations:

if True == True or False == True or False == False:

It is being formatted as:

if (True == True
or False == True
or False == False)

This complicates readability. How can I reformat it to look like the first example?


Solution

  • You can use the shortcut Ctrl+, to open the settings. Input format on save and deselect the Editor:Format On Save option. This disables the use of code formatting when saving documents globally. This preserves the format of the code you wrote it.enter image description here