Aaron Shen
Aaron Shen

Reputation: 8374

How to format vue file using html-beautify & standard in vim?

I'm learning vuejs. I use vim as my editor.

I want to format the template section of a vue component using html-beautify, and format the script section using standard and css with css-beautify.

I'm not sure how can I do this? Any suggestion or recommended format program?

Upvotes: 1

Views: 1349

Answers (1)

dNitro
dNitro

Reputation: 5345

You could visual select your desired lines using linewise visual mode V and run your beautifier on them; for example locate your cursor between <script></script> tag and type: Vit then type :(this will also insert '<,'> which means visual selected lines) then run the system command js-beautify on selected lines using ! operator:

:'<,'>!js-beautify

for css and html also select their regions and run html-beautify or css-beautify

Also check this another answer of mine on how to treat each section separately: change-the-filetype-based-on-tags-regions-in-the-file

Upvotes: 2

Related Questions