Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VS Code Prettier - How to disable auto new lines in function arguments?

I'm using Prettier v6.4.0 and I found it annoying when it automatically add new lines to my function arguments.

For example, this is the format that I desire:

const Header1 = styled.h1`
  ${maxWidth(500, () => css`
    font-size: 36px;
  `)}
`;

However, Prettier would add new lines to the function arguments when it formats the code:

const Header1 = styled.h1`
  ${maxWidth(
    500,
    () => css`
      font-size: 36px;
    `
  )}
`;

How can I configure Prettier to stop the above behavior? I do not want to add // prettier-ignore inside the tagged template literal though, since this format pattern would be very common in my codebase.

like image 915
AnsonH Avatar asked Jun 01 '26 04:06

AnsonH


1 Answers

Change Print Width from User Settings

If you change the width print width from default 80 to 160, it will not add new lines while formatting

like image 121
B Kalra Avatar answered Jun 02 '26 20:06

B Kalra