Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inconvenient Behavior with Enter Key in Python #7911

Closed
vsfeedback opened this issue May 22, 2024 · 1 comment
Closed

Inconvenient Behavior with Enter Key in Python #7911

vsfeedback opened this issue May 22, 2024 · 1 comment
Assignees

Comments

@vsfeedback
Copy link

This issue has been moved from a ticket on Developer Community.


[severity:It bothers me. A fix would be nice]
When using the Enter key in Python editor, there is inconvenient behavior that differs from C# editor. In Python, pressing Enter adds spaces on a new line, whereas in C#, this does not occur. This creates inconvenience and complicates code editing. I constantly have to manually remove these spaces.

Steps to Reproduce the Issue:

  • Open a Python editor.
  • Write code that starts not from the beginning of the line but after a few spaces.
  • Press the Enter key.
  • Notice that extra spaces are added on a new line after pressing Enter (they are visible when selecting the entire code).

Watch the attached video for a visual demonstration:

Expected Behavior:
Pressing Enter should not automatically add spaces on a new line, as observed in the Python editor. The behavior should match that of the C# editor.

Explanation of the Issue:
The problem leads to the following undesirable consequences:

  1. Pressing the backspace key adds spaces to the end of the previous line, which can distort the intended formatting of the code.
  2. The constant appearance and disappearance of spaces create more differences in code versions (Git), leading to frequent code merges and conflicts.
  3. This behavior complicates code editing and readability, making it harder for developers to maintain and collaborate on projects effectively.

Original Comments

Feedback Bot on 5/12/2024, 07:55 PM:

(private comment, text removed)


Original Solutions

(no solutions)

@StellaHuang95
Copy link
Contributor

Hi there, thanks for your issue. In Python, indentation is used to define the structure of code blocks, such as loops, conditional statements, and function definitions. Incorrect indentation can lead to syntax errors or alter the logic of your code.

In C#, indentation is not required for the compiler to understand the structure of your code, as it uses curly braces {} to define code blocks.

But that said, you can still disable smart indentation by going to Options -> Text Editor -> Python -> Tabs and turn off the indenting there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants