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)
After saving: (what I don't want)
Has anyone had this issue? If so, how did you resolve it? Thanks.
Select the text with the line-breaks, then CTRL+J and they are removed.
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.
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.
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.
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 ".
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.
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.
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.
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.
I also added extension: Formatting Toggle.
The extension shows up on the right side of the status bar in editor
disable "JS-CSS-HTML Formatter" extension. It may fix the problem
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With