Velvet Star Monitor

Standout celebrity highlights with iconic style.

news

How to set up Vue files formatting in VS Code?

Writer Sophia Terry

Good day.

I have installed the "Vetur" plugin. And I have nice features for my Vue files (Syntax-highlighting, Snippet, Emmet, Formatting, Auto Completion, Debugging). But I do not understand how to edit formatting settings! it transforms my code from this:

var map = {
q:"й",w:"ц",e:"у",r:"к",t:"е",y:"н",u:"г",i:"ш",o:"щ",p:"з",a:"ф",s:"ы",d:"в",

to that:

var map = { q: "й", w: "ц", e: "у", r: "к", t: "е", y: "н", u: "г", i: "ш", o: "щ",

How can I edit that behavior?

1

2 Answers

Easier method is to install vetur octref.vetur extension and then add a .vscode>settings.json with following

{ "editor.defaultFormatter": "octref.vetur", "vetur.format.defaultFormatter.html": "prettier", "vetur.format.defaultFormatter.css": "prettier", "vetur.format.defaultFormatter.postcss": "prettier", "vetur.format.defaultFormatter.scss": "prettier", "vetur.format.defaultFormatter.less": "prettier", "vetur.format.defaultFormatter.stylus": "stylus-supremacy", "vetur.format.defaultFormatter.js": "prettier", "vetur.format.defaultFormatter.ts": "prettier"
}

enter image description here

3

Vetur uses prettier to format js code. You can see how to configure it here. All options for prettier are here. But as far as I know, there is no way to adjust the wrapping behaviour of object field definition in prettier.

1

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy