How to use Prettier in VS Code - Code Formatting
HTML-код
- Опубликовано: 24 авг 2024
- In this video I will show you how to install and configure Prettier Code Formatter in VS Code. Formatting code consistently can be a challenge, particularly when working on a team. Code formatters like prettier can help solve this issue. Consistent code formatting helps with the readability of a project.
Learn how to setup VS Code to format code whenever a file is saved or code is pasted into VS Code.
Learn how to configure Prettier using a JSON configuration file .prettierrc
Learn the difference between VS Code user settings and VS Code workspace settings.
If you are having trouble getting prettier to work uninstall Prettier Code Formatter extension and follow this video.
Prettier Configuration
prettier.io/do...
Prettier Settings Options
prettier.io/do...
Prettier extension
marketplace.vi...
Bro thank you very much. I searched for this solution everywhere but I didn't find. This video really helped me. Now my prettier is working.
You’re welcome! I’m glad the tutorial was helpful! 😁
Although English is not my first language, I found this tutorial so easy to understand thanks to your excellent and clear explanation! Impressed and subscribed 🤗
Thank you! I’m really happy the video was easy to follow! 😁
"IndentPPDirectives:BeforeHash" is not working, i use too much preprocessing directive and it literally annoying @@CodingWithAdam
Just what I was looking for to resolve my code formatting issue. Thanks Adam!
You’re welcome! really glad the tutorial helped!
presh helped me a lot since im just starting to learn and it takes sooooooo much effort to just press shift lol
Glad the video helped!
now i understant how automatic formatiing the code thanks very much
You’re welcome! Glad the tutorial was helpful! 😁
Clear explanation. Thank you
Thank you. You’re welcome!
wow ,
I didn't know that prettier is so nice before watching this video
thanks for the nice video
You’re welcome! Glad you enjoyed the video.
Explained perfectly.
Thank you!
Thanks for the tutorial!
You’re welcome!
Nice job with explaining bud. Was very easy to understand.
Thank you! Glad you enjoyed the tutorial!
Amazing video. This has saved me lots of time trying to keep my code neat. Thanks!
You’re welcome! I’m really happy you enjoyed the tutorial!
what button do you press on keyboard , so you activate it after you are done with project ?
Be carful with the format on save. When you format code that you have not changed and commit it to git it can make it hard to tell what the REAL changes for the commit are. Easy to work around this, just run prettier on the whole code base (WITHOUT ANYT OTHER CHANGES) then check it in. Then running the formatter on save will not obfuscate the real changes in your commits.
Those are great tips! Thanks!
Thank you sir. great explanation video 👍
You’re welcome! Glad the tutorial was helpful!
LOVE YOUUUUU workspace setting i was stucking on it thank you
You’re welcome! I’m glad the tutorial helped! 😁
Yeah dude, this video nailed it, here is a new sub!
Glad the video helped! Thank you for the Sub!
thanks, this video help me and easy to understand
You’re welcome! Glad the video was easy to understand! 😀
Thank u so much! That was helpful!
You're welcome! Glad the video was helpful.
Thank you for this, I was wondering if I was doing something wrong.
You’re welcome! I’m glad the video helped!
Thanks for the config file and the 'semi' parameter !
You’re welcome!
Thank you! Just what I was looking for.
You’re welcome!
Thanks man. It helps me too much !!!
You’re welcome! Glad the tutorial helped!
Thanks Adam, for to the point explanat. 😀
You’re welcome!
Smooth language and video good job
Thank you!!! Appreciate the feedback!
Thanks
❤
You’re welcome! 😀
This is a good thing you've done
Thank you!
Man, you are the best! thank you for this video !
Thank you! I’m glad you enjoyed the video!
very helpfull video, thanks bro )
You’re welcome!
awesome Tutorial - Thank you Adam.
You’re welcome! 😁
Thank you very much!
You’re welcome! Glad you enjoyed the video!
Very informative. Thank you
Thank you. You’re welcome!
Thanks - very clear.
You’re welcome!
Thank you :)
You’re welcome!!!
perfect vedio than others
Thank you! 😁
awesome video, Thanks for taking the time to do this! helped me get my Sh*T together lol...
You’re welcome! I’m so glad the video helped! 😁
Thanks a lot! Nice tutorial :)
You’re welcome! Glad you enjoyed the tutorial 😁
Great, informative and on point !
Thank You!
very usefull bro! Thanks
You’re welcome! Glad the video was useful.
well explained sir. Thank you! Subscribed
You’re welcome! Thank you for subscribing!
Informative! Thanks for sharing your great experience.
You’re welcome! Happy you enjoyed the video!
Thanks for sharing your tutorial. :D
You’re welcome!
Thank u! Great description! =)
You’re welcome! Thank you :)
Great video, thanks!
Thank you! You’re welcome!
Nice and right to the point!
Thanks!
You’re welcome! Glad you liked the video! 😁
thank you very much sir
You’re welcome!!!
Great job! Thanks for help.
Thank you! You're welcome!
Nice video man make more coding tutorials u rock👑💯
Thank you! 😁
Amazing video!
Thank you! 😁
Thank you!
You’re welcome!
thanks man, this help full me
You’re welcome!
Bro thank you very much
You're welcome! Glad the video helped!
Thanks for the help!
You’re welcome!
Thanks!
You’re welcome!
Amazing top video!
Thank you!
Very helpful, thanks.
You’re welcome!
thanks , it worked for me :)
You're welcome!
Thank you ❤️
You’re welcome! 😀
Thanks for the video :)
You’re welcome!
thanks🥰
You’re welcome!
Thanks man
You’re welcome!
Thank you🎉
You’re welcome 😁
thank you man
You’re welcome!
I installed the plugin but I only have a format with Redhat entry and no prettier ... - am I missing something?
Actually I can set prettier as a default formatter but then it throws an error that it's not available ....
Great one :)
Thank you!
Good one! Tnx
Thank you! You’re welcome!
I started to learn with Angela's Yu course. In the begining she was using Atom and had Beautify, that was great, started to be used of that, but...like everyone has to move to VS, i felt without hands. She had a addon list but didn't know how to "activate" prettier. Thx
You’re welcome! The auto formatting is awesome it’s hard to code with out it. Happy the video helped! 😃
Thanks alot.
You’re welcome!
any help, when i save (autoformat on save) using prettier, some slashes write themself at the very top where there should be a void, such as the meta info and any other. how can i disable or chagne that so it doesnt do that. thanks in advance
Prettier is an opinionated formatter and there are not many settings. That interesting problem.
Amazing video
Thank you! 😁
I have noticed that the option "format document with" only appear if you have an extra formatter installed..if anyone's wondering why they don't see that option.
Thank you for the extra tip. I must have had a few formatters installed.
thanks for this
You’re welcome!
Is there a way so it formats without changing any quote?
I mean ' remain '
And " remain "
Not that I’m aware of. Prettier is very opinionated and does not offer to many options. You can always save a file with out formatting from vscode if you don’t want to format a particular file. Here are the options they provide prettier.io/docs/en/options.html
Appreciate it!
You’re welcome!
My c File code is not formatted...
Unfortunately prettier does not support c files.
Thanks gangy
You’re welcome!
my prettier adds space and slash to the end of my element,
please what can i do to fix this
Thanks for video tutorijal, I'm subscribe, like and share. Bay.
You’re welcome! Thank you for subbing liking and sharing 😁
Thanks
You're Welcome!
thanks!!!
You’re welcome!!!
Thank you.
You’re welcome!
my code is too narrow and looks vertical, what should i do, thanks for the video
You’re welcome. Prettier has configuration for the length of a line I suggest take a look at printWidth prettier.io/docs/en/options.html
Installed prettier but it did not come up in the "Format Document With" menu. Nor was it available as an option when I clicked "Configure Default Formatter".
Restart vs code and then check the extensions tab to see that prettier is installed and enabled
Turns out that prettier will not work with Python. Must use a different formatter for Python.
That’s right you need to use one for python. Glad you figured it out
I been learning js for about a year, but this extension never worked on my pc. I don't know why.
Sorry to hear that.
thxxxxxx very helpfullllll
You’re welcome!
thanks man!
You're Welcome!
Nice Video
Thank you!
bro recently i have been getting some colored boxes whenever i format the code ...its actually at the start of a line of code idk how that happened but i m pretty sure i have my default formatter as prettier .
what exactly happened is that it asked me to configure my formatter out of nowhere i set it to prettier now i m getting wierd colored boxes in the begining of code lines .
Interesting I’m not sure what that is. If I think of anything I’ll let you know.
@@CodingWithAdam thx for the concern, well anyways it was because of indent rainbow extension, i havent installed such ext myself maybe it came as a package with other extension.
I can’t even make a js file!!😢😢😢 why it’s your file showing a path to the file like mine is??? What am I doing wrong, what don’t I know that I don’t know???
I don’t see “code formatting” on my left window, all I have is “open editors” and “outline”, how do I get a “code formatting” option or folder over there????
So we don't need .editorconfig (for indentation) ?
Good question I have never used editorconfig but yes this could replace it if that is the only thing you use it for.
thx bro
You’re welcome!
Have i told you i love you great content we should collab
Can someone help, Whenever I save my JS file prettier adds spaces in my operating chaining operator
let weight3 = baas_pokemon?.pickachu?.weight let weight3 = baas_pokemon ? .pickachu ? .weight
please help.
I understand it's not a linter but can't it still report in the problems filed such as ""No semi-colon required on line x"?. This would be great
Great question, prettier is a code formatter so it’s main purpose is to format the code rather than to report on formatting issues. With linting you can get a report of problems. Hope that helps.
Does anyone know why my HTML is mostly grey and blue, even though I installed and enabled the prettier extension?
Prettier will not change the colors. If you have the wrong file extension it’s possible vscode is not displaying the correct colors.
but this formatter is not working for c cpp and java
Sorry to hear that. Prettier does not work for C. You can try this extension for formatting C files. marketplace.visualstudio.com/items?itemName=ms-vscode.cpptools
Hey can someone tell me that in HTML style if I'm giving curly bracket to a class or Id I'm not getting a line space instead it is showing below to it
Perfect
Thanks!
Hey, do you know how to disable formatting spaces? I just want prettier to add semicolons and single quotes in javascript files but I don't want it to get rid of extra lines in my code. You'd be a live saver!
Unfortunately prettier is a opinionated formatter with very few options. From there website:
Prettier is not a kitchen-sink code formatter that attempts to print your code in any way you wish. It is opinionated. Quoting the Why Prettier? page:
By far the biggest reason for adopting Prettier is to stop all the ongoing debates over styles.
prettier.io/docs/en/option-philosophy.html
nice
Thanks!
Prettier not working on html file, please help
Try this - Inside the html document right click and select ‘“ormat document with” then select prettier.
Why my vscode does not have the option of "format with ..." when right click? Thanks.
I wish I could help with that I have not encountered that issue. If I come across It I will let you know the solution. If you find the answer please post here to help others.