I have set tabstop to 4.

But when I use prettier, it defaults my indentations to 2 spaces.

How do I change this?

I am using the coc prettier extension.

const thing = () => {

    var hi = 1;  //tabstop does this
  var hi2 = 2;   // prettier formats to this

  • Configure prettier to use 4 spaces (?) or :setlocal tabstop=2 maybe?
    – D. Ben Knoble
    Apr 5, 2022 at 16:56
  • I guess the question is how to configure coc prettier to do that. I have read through the docs and I am struggling to understand how to accomplish that,
    – Vinn
    Apr 6, 2022 at 6:24
  • e.g., prettier.io/docs/en/configuration.html
    – D. Ben Knoble
    Apr 6, 2022 at 14:10
  • For anyone who cares, the missing piece for me was "where" to add the settings. Turns out you need to add the prettier settings to the coc-settings.json file. Thanks, Ben for your support.
    – Vinn
    Apr 7, 2022 at 13:53
  • you're quite welcome; please add an answer below!
    – D. Ben Knoble
    Apr 7, 2022 at 15:36

1 Answer 1


For anyone who is facing a similar issue, when you use the prettier extension via coc-prettier, you need to put the configuration options inside the coc-settings.json file.

To solve my issue of prettier tab spaces, I added this:

"prettier.tabWidth": 4

Finally, this page gives a full list of all your other options. https://prettier.io/docs/en/options.html

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.