I think your vscode config and settings and .prettier are not the same. try creating .prettierrc file in your project root and add a prettier config. vscode will automatically pick up the config.

Add all the format-related config in .prettierrc vscode should read the config and format. settings.json is not the right place to add all the prettier config. It'll also be helpful for other team members otherwise when someone commits it'll change the format.

.prettier

{
    "trailingComma": "es5",
    "tabWidth": 4,
    "semi": true,
    "singleQuote": true,
    "printWidth": 120,
    "bracketSpacing": true,
    "jsxBracketSameLine": true
}

.vscode/settings.json

{
    "editor.formatOnSave": true,
    "editor.defaultFormatter": "esbenp.prettier-vscode",
    "[javascript]": {
        "editor.defaultFormatter": "esbenp.prettier-vscode"
    },
    "[jsonc]": {
        "editor.defaultFormatter": "esbenp.prettier-vscode"
    },
    "[html]": {
        "editor.defaultFormatter": "esbenp.prettier-vscode"
    },
    "[javascriptreact]": {
        "editor.defaultFormatter": "esbenp.prettier-vscode"
    },
    "[typescriptreact]": {
        "editor.defaultFormatter": "esbenp.prettier-vscode"
    },
    "editor.codeActionsOnSave": {
        "source.fixAll.eslint": true
    }
}
Answer from Rahul Sharma on Stack Overflow
Discussions

Need help with prettier and vscode
It's a prettier feature: https://prettier.io/docs/en/options.html#print-width Prettier’s printWidth option does not work the same way (as max line length). It is not the hard upper allowed line length limit. It is a way to say to Prettier roughly how long you’d like lines to be. Prettier will make both shorter and longer lines, but generally strive to meet the specified printWidth. Also, in your case, it would be bad if prettier formatted the CLIENTID by inserting newlines thus changing the value. Configuring the IDE to wrap lines visually is the proper solution here. More on reddit.com
🌐 r/vscode
3
2
December 14, 2020
printWidth not working
I am using the prettier plugin and I set the option printWidth but it does not affect how my contracts are printed. More on github.com
🌐 github.com
4
April 19, 2021
`printWidth` not enforced on save
Today, when saving a document, prettier is not respecting the printWidth value in my application settings. I added a .prettierrc file to my project to try to force the desired (default) printWidth ... More on github.com
🌐 github.com
16
April 13, 2018
prettier does not seem to respect printWidth

Run prettier from the command line. If that does what you expect then you can narrow down from there by slowing removing parts of your neovim config.

More on reddit.com
🌐 r/neovim
6
1
May 16, 2024
🌐
Prettier
prettier.io › docs › options
Options · Prettier
In other words, don’t try to use printWidth as if it was ESLint’s max-len – they’re not the same.
🌐
JetBrains
intellij-support.jetbrains.com › hc › en-us › community › posts › 19094549935634-Prettier-printWidth-not-working-with-strings
Prettier printWidth not working with strings – IDEs Support (IntelliJ Platform) | JetBrains
May 22, 2024 - i tried using softwrap but it looks ugly as it breaks at the edge, i want to maintain my 120 printWidth ... This is the Prettier own behavior since version 2.5, please refer to https://prettier.io/blog/2021/11/25/2.5.0.html#html. Feel free to leave your comments in https://github.com/prettier/prettier/issues/7863 and https://github.com/prettier/prettier/issues/10918.
🌐
GitHub
github.com › prettier-solidity › prettier-plugin-solidity › issues › 479
printWidth not working · Issue #479 · prettier-solidity/prettier-plugin-solidity
April 19, 2021 - I am using the prettier plugin and I set the option printWidth but it does not affect how my contracts are printed.
Author: prettier-solidity
🌐
GitHub
github.com › prettier › prettier-vscode › issues › 417
`printWidth` not enforced on save · Issue #417 · prettier/prettier-vscode
April 13, 2018 - Today, when saving a document, prettier is not respecting the printWidth value in my application settings. I added a .prettierrc file to my project to try to force the desired (default) printWidth of 80: { "printWidth": 80, "indent": 2 }...
Author: prettier
Find elsewhere
🌐
Reddit
reddit.com › r/neovim › prettier does not seem to respect printwidth
r/neovim on Reddit: prettier does not seem to respect printWidth
May 16, 2024 -

Prettier formatting does not seem to abide by the `printWidth` rule in my `.prettierrc`.
I have set `printWidth: 999` to demonstrate the issue clearly. Now,

<div class="flex min-w-[600px] h-full min-h-[800px] snap-start snap-always flex-col items-center justify-center gap-8 text-white"><h1>something</h1></div>

formats to

<div
  class="flex h-full min-h-[800px] min-w-[600px] snap-start snap-always flex-col items-center justify-center gap-8 text-white">
  <h1>something</h1>
</div>

as you can see, the formatter does work and even the classes get rearranged in the recommended tailwind order, the long class variable is moved to a new line even though the printWidth I have set should allow everything in that tag stay on the same line.

I use NvChad, here is my `conform.lua`

local options = {
  formatters_by_ft = {
    lua = { "stylua" },
    css = { "prettier" },
    html = { "prettier" },
    javascript = { "prettier" },
    typescript = { "prettier" },
    svelte_fmt = {
      command = "prettier",
      args = { "--plugin", "prettier-plugin-svelte", "$FILENAME" },
    },
  },

  format_on_save = {
    -- These options will be passed to conform.format()
    enabled = true,
    timeout_ms = 2000,
    lsp_fallback = true,
  },
}
require("conform").setup(options)

and here is the `.prettierrc` in the root of my svelte project

{
  "useTabs": true,
  "singleQuote": true,
  "trailingComma": "none",
  "printWidth": 999,
  "bracketSameLine": true,
  "plugins": [
    "prettier-plugin-svelte",
    "prettier-plugin-tailwindcss"
  ],
  "overrides": [
    {
      "files": "*.svelte",
      "options": {
        "parser": "svelte"
      }
    }
  ]
}

after running `:LspInfo`

What could be causing this?

🌐
GitHub
github.com › antfu › eslint-config › issues › 572
default prettier `printWidth: 120` not work as expected · Issue #572 · antfu/eslint-config
August 4, 2024 - printWidth: 120 is only set for markdown / slidev, others will fallback to use prettier's default 80.
Author: antfu
🌐
GitHub
github.com › prettier › prettier › issues › 5842
printWidth not respecting line width · Issue #5842 · prettier/prettier
February 8, 2019 - When executing prettier --config ./.prettierrc.json --write src/filename printWidth is consistently not working as expected. Example line not being formatted: export const EXPERIMENT_CREATION_NAME_LENGTH_ERROR = "Max length of Experiment...
Author: prettier
🌐
GitHub
github.com › prettier › prettier-vscode › issues › 786
`printWidth` option is ignored · Issue #786 · prettier/prettier-vscode
That didn't work, so I also created a .prettierrc file in my project's root directory and my home directory: { "trailingComma": "es5", "tabWidth": 2, "useTabs": false, "singleQuote": true, "printWidth": 150, "bracketSpacing": true, } Still nothing, so I also created a .editorconfig file in both the project root and my home directory: max_line_length = 150 ·
Author: prettier
🌐
GitHub
github.com › prettier › prettier › issues › 14225
"prettier.printWidth: xx" - not-working · Issue #14225 · prettier/prettier
January 23, 2023 - Prettier 2.8.3 Playground link # Options (if any): --single-quote Input: // code snippet Output: // code snippet Expected behavior:
Author: prettier
🌐
Reddit
reddit.com › r/vscode › prettier ignoring printwidth and forcing 80 columns?
r/vscode on Reddit: Prettier ignoring PrintWidth and forcing 80 columns?
March 14, 2021 - EDIT: Turns out prettier only loads the rc at startup, so reloading the window fixed it :|. I'm a Dumb Brain. Hi all, Prettier appears to steadfastly…
🌐
GitHub
github.com › prettier › prettier › issues › 16783
printWidth behavior suddenly changed · Issue #16783 · prettier/prettier
October 24, 2024 - recently i noticed, that the default behavior of auto-formatting has changed. I even tested on the prettier playground and the same changes that are effecting my code base are also happening on the official site. At the moment, the printWidth option is ignored in some cases, but not in others.
Author: prettier
🌐
Stack Overflow
stackoverflow.com › questions › 78907974 › sometimes-the-printwidth-option-in-prettier-is-applied-but-sometimes-it-is
Sometimes the "printWidth" option in "prettier" is applied, but sometimes it is not
Prettier’s printWidth option does not work the same way. It is not the hard upper allowed line length limit. It is a way to say to Prettier roughly how long you’d like lines to be. Prettier will make both shorter and longer lines, but generally strive to meet the specified printWidth.
🌐
GitHub
github.com › prettier › prettier › issues › 17291
prettier.format doesn't apply printWidth · Issue #17291 · prettier/prettier
March 28, 2025 - I want prettier to shrink the print width to 70 but it doesn't do it: const printWidth = 70; const formatted = await prettier.format(node.value, { parser: 'typescript', endOfLine: 'lf', printWidth, }); const newLines = formatted.split('\n'); newLines.forEach(line => { if (line.length > printWidth) { console.log('prettier', line.length); } });
Author: prettier