最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How can I disable auto new-line in Visual Studio Code? - Stack Overflow

programmeradmin6浏览0评论

The problem is after I've installed the Angular extension in Visual Studio Code, I constantly get across all files (.ts, .html, and .css) auto new-line after typing single letters or multiple lines of code. It's frustrating. I disabled prettier, word-wrap, and intellisense, but the problem still remains.

Is there a way I can disable it?

The problem is after I've installed the Angular extension in Visual Studio Code, I constantly get across all files (.ts, .html, and .css) auto new-line after typing single letters or multiple lines of code. It's frustrating. I disabled prettier, word-wrap, and intellisense, but the problem still remains.

Is there a way I can disable it?

Share Improve this question edited May 11, 2022 at 0:06 Peter Mortensen 31.6k22 gold badges110 silver badges133 bronze badges asked Jan 17, 2021 at 9:08 ahsibobahsibob 811 gold badge1 silver badge2 bronze badges 4
  • Can you give an example of what you type and when/where it adds the newline? – T.J. Crowder Commented Jan 17, 2021 at 9:10
  • is the typed line is the last line in VS code? – Onkar Commented Jan 17, 2021 at 9:13
  • 1 I type 'e' it goes new line...i type 'export' it goes new line...it's doing it in every file type. 'Insert New Line At the End Of File' is disabled – ahsibob Commented Jan 17, 2021 at 10:25
  • Possible duplicate: Visual Studio Code — Insert New Line at the End of Files – Peter Mortensen Commented May 11, 2022 at 0:06
Add a ment  | 

4 Answers 4

Reset to default 12

I had the same problem.

After going through my extensions, I noticed that the "EditorConfig for VS Code" extension I installed was inserting auto new-line after typing single or multiple lines of code.

If the problem is still not solved, try disabling some extensions and see if that works.

I had a similar issue and the solution provided by 9paradox solved my problem.

When I was saving my code (Python, JSON, JS, etc...) I got always a new line inserted at the end of the file.

Solution: if, e.g. on Mac, you are editing any file in your project, then go to the root directory of your project, let's say /Users/<username>/git/<project> then search for .editorconfig in that folder, then open that file with any text editor like vi or TextEdit and make insert_final_newline = false. VS Code takes over the settings changes immediately. No restart needed.

I had the same problem / frustration, particularly with Angular .html (.css lines don't get that lengthy anyway, and my team is tight with the .ts formatting standards).

Search vscode settings for HTML > Format: Wrap Attributes and HTML > Format: Wrap Line Length and play with the options.

In the end I had to revert since other team members were using the system defaults, git was going to show way too many changes. But if you're working on your own thing then this works. Don't forget you can also change the settings just for a particular workspace.

Just disable the auto save option in VSC.

发布评论

评论列表(0)

  1. 暂无评论