Nelson Uprety
Nelson Uprety

Reputation: 143

My code automatically goes to another line in VS-Code after I type anything. How do i fix this issue?

How do i fix this problem of VS-Code in which it automatically jumps to next line after i type in one letter. Here is the example of the problem in the image It automatically goes into next line without the pressing the enter key. How do I solve this issue?This is the problem jumping into next line

Upvotes: 12

Views: 12173

Answers (3)

meraga
meraga

Reputation: 59

In Visual Studio Code, autosave automatically saves your files as you work on them. When autosave is enabled, it triggers a file save operation in the background, which can cause the cursor to move to the next line after you type anything. This behavior is a result of the code editor responding to the file save event.

To prevent this issue, you can disable the autosave feature in Visual Studio Code. Here's how to do it:

  1. Open Visual Studio Code.
  2. Go to "File" in the menu bar and select "Preferences," then choose "Settings."
  3. In the settings panel, search for "Auto Save" in the search bar.
  4. Look for the "Files: Auto Save" setting.
  5. Click on the dropdown menu next to "Files: Auto Save" and select "off."
  6. Close the settings panel. Disabling autosave will prevent the automatic save operation that triggers the code editor to jump to the next line after typing.

It's worth noting that by disabling autosave, you'll need to manually save your files using the "Save" command (shortcut: Ctrl + S or Cmd + S) to persist your changes.

By following these steps to disable autosave in Visual Studio Code, you should be able to resolve the issue of your code automatically going to the next line after typing.

Upvotes: 4

Craole
Craole

Reputation: 341

I had the same issue. I found that the issue was because I had insert_final_newline = true in an .editorconfig file at the root of my workspace.

Change that value to false, comment it out or remove the file altogether.

I arrived at this solution after disabling all extensions then enabling them individually. EditorConfig for VS Code was the plugin caused the issue.

Upvotes: 24

Enes Cinar
Enes Cinar

Reputation: 61

there might be several reasons.

  • you may want to check the settings below; files.insertFinalNewline
  • there might be an extension settings / such as eslint, prettier, etc.

Upvotes: 1

Related Questions