Use case: I'm using Neoformat for vim, where I select a snippet (e.g. the insides of an if-statement), and run it through prettier. I'd like to keep the indentation of the first line and reformat the snippet accordingly. Assume this code:
....
if (true) {
doSomething(); doSomethingElse();
}
....
Assume the doSomething(); doSomethingElse(); line starts on column 7 (First column is column 1).
Expected result: doSomething() starts on column 7 after being run through prettier and doSomethingElse() also starts on column 7 on the next line.
Actual result: Both lines start on column 1, not column 7.
Workaround
I can create a wrapper script that checks the amount of indentation of the first line. Subtract this number from 80 and give that to --print-width. Run prettier, and subsequently re-indent the entire prettier output that amount of spaces.
But it would be handy if prettier would do that for me - perhaps behind an option.
Use case: I'm using Neoformat for vim, where I select a snippet (e.g. the insides of an if-statement), and run it through
prettier. I'd like to keep the indentation of the first line and reformat the snippet accordingly. Assume this code:Assume the
doSomething(); doSomethingElse();line starts on column 7 (First column is column 1).Expected result:
doSomething()starts on column 7 after being run throughprettieranddoSomethingElse()also starts on column 7 on the next line.Actual result: Both lines start on column 1, not column 7.
Workaround
I can create a wrapper script that checks the amount of indentation of the first line. Subtract this number from 80 and give that to
--print-width. Run prettier, and subsequently re-indent the entire prettier output that amount of spaces.But it would be handy if
prettierwould do that for me - perhaps behind an option.