I have add Prettier in my VScode but I want to format my code only when I highlight my code, say
let a = [1, 2, 3, 4]; (line1)
let b = [ 1,2 ,3,4]; (line3)
how can I just format line 1 when I highlight line 1 only and the result should be
let a = [1, 2, 3, 4]; (line1)
let b = [ 1,2 ,3,4]; (line3)
thanks
UPDATE: I know we can format the code in a code block. But what I want to do is
const test = (a, b, c) => { (line 1)
console.log("show a", a); (line 2)
console.log("show b", b); (line 3)
}
If I highlight b, c
in line 1 and format it. It only formats the code in line 1 but not 2 and 3
CodePudding user response:
Select the code you want to format and press CTRL SHIFT P to open the command pallette. Then type in "format" and select format selected code. Or you can select your code and press right click which should bring up a context menu where you can select the option
CodePudding user response:
Select the code or leave the cursor in the row you want to format and press Ctrl K Ctrl F
.