Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VS Code: Line break being removed on save

We have an app written in angularJS and I want to align the directives vertically for easier reading. However, when I insert a line break in a tag and save the file, the line break is removed and the directives remain on the same line. I've disabled all extensions and it still doesn't work on save. Why is VS Code ignoring the line break?

Before saving: (what I want)

enter image description here

After saving: (what I don't want)

enter image description here

Has anyone had this issue? If so, how did you resolve it? Thanks.

like image 770
Chris22 Avatar asked Nov 07 '18 21:11

Chris22


People also ask

How do you remove line breaks in VS Code?

Select the text with the line-breaks, then CTRL+J and they are removed.

How do you resolve Save conflict VS Code?

VS Code blocks saving the file to prevent overwriting changes that have been made outside of the editor. Use the actions in the editor toolbar to resolve the save conflict. You can either Accept your changes and thereby overwriting any changes on disk, or Revert to the version on disk.

What does Ctrl d do in VS Code?

Ctrl+D selects the word at the cursor, or the next occurrence of the current selection. Tip: You can also add more cursors with Ctrl+Shift+L, which will add a selection at each occurrence of the current selected text.

What is Ctrl P in VS Code?

Quick file navigation# Tip: You can open any file by its name when you type Ctrl+P (Quick Open). The Explorer is great for navigating between files when you are exploring a project.

Does VSCode automatically add new lines on save?

After more research, I came across this post VSCode automatically adding new lines on save via a google search of " line break in visual studio code is removed on save ".

How do I change the line break in Visual Studio Code?

At the bottom right of the screen in VS Code, click the little button that says LF or CRLF. After changing it to your preference, Voila, the file you’re editing now has the correct line breaks. The pace of Boot.dev's JavaScript, Python and Go courses has been perfect for me.

How do I remove extra line breaks in plain text messages?

To do this, follow these steps: For Outlook 2010 and later versions: Open Outlook. On the File tab, select Options. In the Options dialog, select Mail. In the Message format section, clear the Remove extra line breaks in plain text messages check box. Select OK.

How do I add line break characters to a Word document?

You can use the File > Advanced Save Options dialog box to determine the type of line break characters you want. You can also change the encoding of a file with the same settings. If you don't see Advanced Save Options on the File menu, you can add it.


2 Answers

After more research, I came across this post VSCode automatically adding new lines on save via a google search of "line break in visual studio code is removed on save". Even though the issue I was having was that I DID want a new line, and this question was just the opposite, I looked at the answer anyway since everything else I was finding was about "VSCode removing or adding new lines at the end of file" (for example) -- which isn't what I wanted. Unchecking the Format On Save setting as shown worked for what I wanted to do.

enter image description here

I also added extension: Formatting Toggle.

enter image description here

The extension shows up on the right side of the status bar in editor

enter image description here

like image 85
Chris22 Avatar answered Oct 19 '22 02:10

Chris22


disable "JS-CSS-HTML Formatter" extension. It may fix the problem

like image 6
Fatemeh Talebi Avatar answered Oct 19 '22 02:10

Fatemeh Talebi