I am using Vim (neovim) for the past couple of weeks now. I am facing one problem with the way vim formats the code. My other team members uses vscode which formats JS file on Save something like this:

function test(test,test){
  const {getter,setter} = dummyObj;

The above code gets formated into:

function test(test, test) { // Notice the space between params
  const { getter, setter } = dummyObj; // Notice the space between destructed variables

And Vim does exactly the opposite, which is on save file it removes any spaces between params and etc.

So when I save a file in nvim if that was saved in Vscode earlier it will now format by my nvim. And these changes will be counted as modification in GIT

Does anybody notice or encounter this issue? How you are tacking it?

The plugin I am using is: coc-vim

and I have added auto-format on save the file in coc-vim configuration file:

    "suggest.noselect": false,
    "coc.preferences.formatOnSaveFiletypes": [

1 Answer 1


I have managed to solve this issue with the following:

Note: First thing if you are new to vim, neovim do check your settings and prettier settings for the project.

To solve this issue, first I check with my project requirements in terms of prettier and how and what formatting my project requires. Based on that I have installed coc-prettier plugging and added required rules in coc-settings.json like the followings:

    "prettier.arrowParens": "avoid",
    "prettier.semi": true,
    "prettier.singleQuote": true,
    "prettier.tabWidth": 2

After this as well I was facing some issues with arrowParens. Like even it is specified that arrow parans should be avoided in case of single params, somehow coc-prettier was picking up settings from somewhere in the project and applying opposite of the rule.

So to tackle this I have added my own .prettierrc in the project root, which is put in .gitignore, and added a rule to overwrite arraowparans behavior as expected.

With these settings, I am able to get to a place where 99% of required formatting by my project is handled by neovim now

I said 99% because I am still facing one issue: In case of importing functions using destructor in multiline format like:

const {
} = require('./fooModule');

The Prettier / Formatter formats this in one line like this:

const { fooFunction, foo2Function } = require('./fooModule');

because of this, the existing code base having such formatting changes.

But I think I can live with it until I get any solution.

For more information on settings, you check out following links:

https://github.com/neoclide/coc-prettier https://gist.github.com/sidgujrathi/5e60ba7faf677d550264456ca37e3f32 https://gist.github.com/sidgujrathi/77ac41b72bab472bfbe1762c423ca5fd

Your Answer

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

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