Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove line break and all spaces on the next line in sublime text editor?

It happens many times when we need to remove line end and unnecessary space between the HTML element. So this could be proven as a time-saving technique.

like image 698
shekhardtu Avatar asked Jun 01 '16 12:06

shekhardtu


People also ask

How do I remove spaces between lines in Sublime Text?

Ctrl + H on PC, or. Command + Alt + F on Mac or.


2 Answers

  1. open Search and replace (CTRL+H)
  2. enable "Regular Expression" (circled in red)
  3. enter \n\s+ in the search field, clear the replace field
  4. press "Replace all"

enter image description here

This will remove all newlines (\n+) followed by all whitespace (\s+) in the next line.

like image 160
Gerald Schneider Avatar answered Sep 23 '22 08:09

Gerald Schneider


In your Sublime Text user settings, you can specify the following to trim trailing white space.

"trim_trailing_white_space_on_save": true 

You might want to have a look at the Trimmer that has a couple of options to trim whitespace.

like image 39
idleberg Avatar answered Sep 23 '22 08:09

idleberg