My code is automatically formatted by the formatter, and it adds blank lines that I do not want. This happens while using both autopep8 and black. This is my code:
dict_n = {}
def new_dash():
new_list = input("do something ").split(",")
for i in range(len(new_list)):
# dict_n[new_list[i]] = [i]
dict_n[i] = new_list[i]
print(dict_n)
new_dash()
which gets formatted to:
dict_n = {}
def new_dash():
new_list = input("do something ").split(",")
for i in range(len(new_list)):
# dict_n[new_list[i]] = [i]
dict_n[i] = new_list[i]
print(dict_n)
new_dash()
Is there a way I can prevent the extra lines being added automatically by the formatter, possibly by editing the settings.json file in VSCode?
First of all, this is a formatting standard, for the sake of code specification and code readability, etc. Generally, it is not recommended to change it.
If you really want to change, the following is a solution, but it can only remove the blank lines above. To add the following settings in settings.json,
See more about this settings here.