简体   繁体   中英

Prevent vscode automatic add two space after enter in python file

I am writing python code in vscode, after an expression, each time I hit enter to start a new line, it will automatic add one space for the newline.

Instead, what I really want is the starting new line would be aligned with the start of the statement, ie:

def fun():
    arg = 'fake'
    cursor should be aligned with arg

Now what I got is the cursor is one space of the start. I searched and couldn't find out where to set this, the Tab Size is 4 space.

I still don't find out the causing issue, but on my project I solved it by setting black path to my absolute path. The answers provided below is not the reason why it doesn't work in my vscode. I attached the pic here. My vscode shortcut

使用Ctrl + Shift + P打开命令面板,输入Indent with spaces ,按Enter并选择4

Set also the tab size at the status bar to 4 instead of 2 and you're good to go. 在此处输入图片说明

Your situation for now:

在此处输入图片说明

Click Space:2 and select Indent Using Space :

在此处输入图片说明

Slect 4:

在此处输入图片说明

It should be work:

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM