0

BTW, this is not asking how to format code in VS, or the keybinding, so please don't mark it duplicate of this. It is specifically about formatting during typing.

Given the following code:

if(true) {
    console.log('hello');
    console.log('world');
}

If I go to the end of the 'log hello' line, hit DEL to bring 'log world' to the end of the line I will get (with | representing my cursor):

if(true) {
    console.log('hello');|        console.log('world');
}

Now, if I hit ENTER, I will get:

if(true) {
    console.log('hello');
    |        console.log('world');
}

In other editors I would expect the white space to be 'eaten up' and the line to be reformatted, looking like this again:

if(true) {
    console.log('hello');
    |console.log('world');
}

Any thoughts on how to change this behavior?

This would also (hopefully) handle the pasting in of code that was not properly formatted, for instance, if I wanted to paste the following in:

                console.log('arrrgg');
            console.log('matey');

To the end of the if, I would see:

if(true) {
    console.log('hello');
    console.log('world');
                        console.log('arrrgg');
            console.log('matey');
}

Instead of:

if(true) {
    console.log('hello');
    console.log('world');
    console.log('arrrgg');
    console.log('matey');
}

Certainly, I can hit Shift-Alt-F and reformat, but I don't always want to reformat an entire file....

I think I have been spoiled with VS and WebStorm automatically cleaning up and reformatting code quickly. Not sure if that is a valid

Is this even possible in Code?

Community
  • 1
  • 1
Joshua Ball
  • 23,260
  • 6
  • 27
  • 29

0 Answers0