Ah, yet another of my selfish uses of this Stack.
Being a Chromebook owner, I'm a frequent user of the Ace IDE, the editor used by Cloud9. It has lots of tools for dealing with excess whitespace, but it notably lacks one: clearing empty lines.
Your mission today is, given an input from a place I can copy-paste to [;)
], output something identical, save all spaces and tabulators on otherwise empty lines.
I'll give some examples, with #
s representing whitespace characters to be removed.
INPUT 1:
if (this.Color !== 'blue') {
##
this.Color = 'blue';
}
OUTPUT:
if (this.Color !== 'blue') {
[empty line]
this.Color = 'blue';
}
INPUT 2:
function outputSomething(times) {
for (var iter = 0; iter < times; iter++) {
console.log('"# # " represents a tabulator');
// This is a comment
# #
}}
OUTPUT:
function outputSomething(times) {
for (var iter = 0; iter < times; iter++) {
console.log('"# # " represents a tabulator');
// This is a comment
[empty line]
}}
INPUT 3:
var x = 'Do you prefer spaces or tabs?';
var y = 'I\'m using both here. Sue me.';
# # ####
console.log(x + ' ' + y);
OUTPUT:
var x = 'Do you prefer spaces or tabs?';
var y = 'I\'m using both here. Sue me.';
[empty line]
console.log(x + ' ' + y);
You may process the input however you like. Output wherever, so long as I can copy-paste from it [;)
].
Standard loopholes apply, shortest answer in bytes wins!
[empty line]
, or no line at all? \$\endgroup\$