Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sublime 3: Is there a way to remove tabs/spaces from empty lines?

I am looking for a way to force Sublime 3 to remove all spaces and tabs from any indented line that is empty in my code, either when I save the file or as I am typing.

Is there a way?

|
if (...) {
    |
    some code
    |
}

to

|
if (...) {
|
    some code
|
}
like image 381
exbuddha Avatar asked Sep 02 '17 22:09

exbuddha


People also ask

How do I delete a tab in Sublime Text?

Edit - Line - Unindent (or it's keyboard shortcut). And shift + tab works as well.

How do I remove a tab from a certain text?

If you want to remove one tab, you can click that tab to select it, then click the minus button (-) to remove it.

How do I change the spacing in Sublime Text?

Changing default indentation settings The following File Type Preferences determine the indentation settings: translateTabsToSpaces: set to either 'true' or 'false'. If true, then when tab is pressed, an equivalent number of spaces will be inserted into the buffer instead. Defaults to false.


1 Answers

Add this to your preferences (Preferences > Settings):

"trim_trailing_white_space_on_save": true

This will remove whitespaces from the end of all lines, even empty ones, when you save the file.

Quoting the default settings file:

// Set to true to removing trailing white space on save
"trim_trailing_white_space_on_save": false,
like image 194
juzraai Avatar answered Oct 13 '22 00:10

juzraai