Anny
Anny

Reputation: 19

How to remove the empty lines in an html file

In the image below there are empty lines before the head, body and closing /html tags and within the body tag I want to remove. How?

html file with empty lines

Upvotes: 1

Views: 892

Answers (3)

Mark
Mark

Reputation: 180651

Use \n\n* in the Find Widget (Ctrl+H) with the regex option (.*) icon enabled, replace with \n. Replace All.

or better change this setting:

// List of tags, comma separated, that should have an extra newline before them. `null` defaults to `"head, body, /html"`.
`HTML > Format: Extra Liners`

In your settings.json:

"html.format.extraLiners": ""  // just leave empty

Now when you format the html file those empty lines above head/body/\html should be removed (select all and Command Palette: Format Selection).

Upvotes: 1

DarkStark9000
DarkStark9000

Reputation: 16

According to your screenshot, you can try to reduce the line height to reduce the gaps between two successive lines.

  1. Open Settings
  2. Type Line height in the search bar
  3. Specify your desired line height

And done.

Also you could try reducing your font size which would automatically decrease the line height thus reducing gaps in between successive lines.

Settings section of VS Code editor

Upvotes: 0

rioV8
rioV8

Reputation: 28623

  • put cursor at end of line with text
  • press Shift-ArrowRight as many times till cursor at pos 1 selecting all newlines till next text
  • Ctrl+Shift+L to select all similar parts
  • ArrowRight
  • Backspace as much times as needed
  • Esc to leave multi cursor

Upvotes: 1

Related Questions