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...

Комментарии • 234

  • @pubgm7262
    @pubgm7262 3 месяца назад +10

    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.

    • @CodingWithAdam
      @CodingWithAdam  3 месяца назад +1

      You’re welcome! I’m glad the tutorial was helpful! 😁

  • @user-xj2mt1rp2v
    @user-xj2mt1rp2v Год назад +20

    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 🤗

    • @CodingWithAdam
      @CodingWithAdam  Год назад +3

      Thank you! I’m really happy the video was easy to follow! 😁

    • @MrNams
      @MrNams 7 месяцев назад

      "IndentPPDirectives:BeforeHash" is not working, i use too much preprocessing directive and it literally annoying @@CodingWithAdam

  • @soumitralahiri6328
    @soumitralahiri6328 Год назад +14

    Just what I was looking for to resolve my code formatting issue. Thanks Adam!

    • @CodingWithAdam
      @CodingWithAdam  Год назад +1

      You’re welcome! really glad the tutorial helped!

  • @Varyeth
    @Varyeth Год назад +2

    presh helped me a lot since im just starting to learn and it takes sooooooo much effort to just press shift lol

  • @sandeepnandanwar5240
    @sandeepnandanwar5240 3 месяца назад +2

    now i understant how automatic formatiing the code thanks very much

    • @CodingWithAdam
      @CodingWithAdam  3 месяца назад +1

      You’re welcome! Glad the tutorial was helpful! 😁

  • @narekmusakhanyan523
    @narekmusakhanyan523 2 года назад +9

    Clear explanation. Thank you

  • @fighter8931
    @fighter8931 Год назад +3

    wow ,
    I didn't know that prettier is so nice before watching this video
    thanks for the nice video

    • @CodingWithAdam
      @CodingWithAdam  Год назад +1

      You’re welcome! Glad you enjoyed the video.

  • @kirankumarsukumar
    @kirankumarsukumar Год назад +8

    Explained perfectly.

  • @ravimakwana992
    @ravimakwana992 4 месяца назад +2

    Thanks for the tutorial!

  • @cjcro6456
    @cjcro6456 Год назад +5

    Nice job with explaining bud. Was very easy to understand.

  • @erickchavez4551
    @erickchavez4551 Год назад +9

    Amazing video. This has saved me lots of time trying to keep my code neat. Thanks!

    • @CodingWithAdam
      @CodingWithAdam  Год назад +1

      You’re welcome! I’m really happy you enjoyed the tutorial!

    • @BobDenton655
      @BobDenton655 9 месяцев назад

      what button do you press on keyboard , so you activate it after you are done with project ?

  • @JohnAshleyMckenzie
    @JohnAshleyMckenzie Год назад +11

    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.

  • @mattvalgreen
    @mattvalgreen 5 месяцев назад +1

    Thank you sir. great explanation video 👍

    • @CodingWithAdam
      @CodingWithAdam  5 месяцев назад

      You’re welcome! Glad the tutorial was helpful!

  • @entrinsek9230
    @entrinsek9230 4 месяца назад

    LOVE YOUUUUU workspace setting i was stucking on it thank you

    • @CodingWithAdam
      @CodingWithAdam  4 месяца назад

      You’re welcome! I’m glad the tutorial helped! 😁

  • @elcancion
    @elcancion Год назад +3

    Yeah dude, this video nailed it, here is a new sub!

    • @CodingWithAdam
      @CodingWithAdam  Год назад +1

      Glad the video helped! Thank you for the Sub!

  • @alkhiddier9407
    @alkhiddier9407 3 месяца назад +2

    thanks, this video help me and easy to understand

    • @CodingWithAdam
      @CodingWithAdam  3 месяца назад +1

      You’re welcome! Glad the video was easy to understand! 😀

  • @inescherif5385
    @inescherif5385 21 день назад +2

    Thank u so much! That was helpful!

    • @CodingWithAdam
      @CodingWithAdam  14 дней назад +2

      You're welcome! Glad the video was helpful.

  • @quatron9561
    @quatron9561 Год назад +3

    Thank you for this, I was wondering if I was doing something wrong.

    • @CodingWithAdam
      @CodingWithAdam  Год назад +2

      You’re welcome! I’m glad the video helped!

  • @achillesus7
    @achillesus7 2 года назад +2

    Thanks for the config file and the 'semi' parameter !

  • @jeffreyhunter4115
    @jeffreyhunter4115 Год назад +2

    Thank you! Just what I was looking for.

  • @duyphuongnguyen431
    @duyphuongnguyen431 4 месяца назад +1

    Thanks man. It helps me too much !!!

    • @CodingWithAdam
      @CodingWithAdam  4 месяца назад

      You’re welcome! Glad the tutorial helped!

  • @isatyamshivam
    @isatyamshivam Год назад +4

    Thanks Adam, for to the point explanat. 😀

  • @masrado3195
    @masrado3195 Год назад +2

    Smooth language and video good job

  • @3amnatural
    @3amnatural Год назад +2

    Thanks

  • @nickgannon7466
    @nickgannon7466 Год назад +1

    This is a good thing you've done

  • @carlosbracho1304
    @carlosbracho1304 8 месяцев назад +1

    Man, you are the best! thank you for this video !

    • @CodingWithAdam
      @CodingWithAdam  8 месяцев назад

      Thank you! I’m glad you enjoyed the video!

  • @simpleview1433
    @simpleview1433 Год назад +2

    very helpfull video, thanks bro )

  • @michalroesler
    @michalroesler 11 месяцев назад +2

    awesome Tutorial - Thank you Adam.

  • @robsongrubba
    @robsongrubba 10 дней назад +2

    Thank you very much!

    • @CodingWithAdam
      @CodingWithAdam  8 дней назад +1

      You’re welcome! Glad you enjoyed the video!

  • @rhymekidstv
    @rhymekidstv Год назад +2

    Very informative. Thank you

  • @tullyendicott6700
    @tullyendicott6700 Год назад +2

    Thanks - very clear.

  • @sebastianantoniochaviracha4845
    @sebastianantoniochaviracha4845 Год назад +2

    Thank you :)

  • @ahmadkhalil970
    @ahmadkhalil970 10 месяцев назад +1

    perfect vedio than others

  • @JohnGallie
    @JohnGallie 2 месяца назад +3

    awesome video, Thanks for taking the time to do this! helped me get my Sh*T together lol...

    • @CodingWithAdam
      @CodingWithAdam  2 месяца назад +1

      You’re welcome! I’m so glad the video helped! 😁

  • @LcyYoutube
    @LcyYoutube Год назад +2

    Thanks a lot! Nice tutorial :)

    • @CodingWithAdam
      @CodingWithAdam  Год назад

      You’re welcome! Glad you enjoyed the tutorial 😁

  • @mouatezbenariba
    @mouatezbenariba 2 года назад +10

    Great, informative and on point !

  • @gabriel5591
    @gabriel5591 28 дней назад +2

    very usefull bro! Thanks

    • @CodingWithAdam
      @CodingWithAdam  14 дней назад +1

      You’re welcome! Glad the video was useful.

  • @ashimghoshfm
    @ashimghoshfm Год назад +2

    well explained sir. Thank you! Subscribed

    • @CodingWithAdam
      @CodingWithAdam  Год назад +1

      You’re welcome! Thank you for subscribing!

  • @gfxmentoring
    @gfxmentoring Год назад +2

    Informative! Thanks for sharing your great experience.

    • @CodingWithAdam
      @CodingWithAdam  Год назад +1

      You’re welcome! Happy you enjoyed the video!

  • @patrickhollywood93
    @patrickhollywood93 Год назад +2

    Thanks for sharing your tutorial. :D

  • @karinapsheny5063
    @karinapsheny5063 Год назад +2

    Thank u! Great description! =)

  • @juggles5474
    @juggles5474 10 месяцев назад +1

    Great video, thanks!

  • @staycalm4957
    @staycalm4957 Год назад +1

    Nice and right to the point!
    Thanks!

    • @CodingWithAdam
      @CodingWithAdam  Год назад +1

      You’re welcome! Glad you liked the video! 😁

  • @hastudent738
    @hastudent738 Год назад +2

    thank you very much sir

  • @crowning8691
    @crowning8691 Год назад +1

    Great job! Thanks for help.

  • @CieloGotCash
    @CieloGotCash Год назад +2

    Nice video man make more coding tutorials u rock👑💯

  • @jiazhengliu2137
    @jiazhengliu2137 Год назад +2

    Amazing video!

  • @araitmai
    @araitmai 2 месяца назад +2

    Thank you!

  • @agusalfandi6672
    @agusalfandi6672 2 года назад +2

    thanks man, this help full me

  • @user-gm5vf8iv1i
    @user-gm5vf8iv1i 3 месяца назад +2

    Bro thank you very much

    • @CodingWithAdam
      @CodingWithAdam  3 месяца назад +1

      You're welcome! Glad the video helped!

  • @ashaysaoji2273
    @ashaysaoji2273 9 месяцев назад +1

    Thanks for the help!

  • @evgehaplay4912
    @evgehaplay4912 Год назад +1

    Thanks!

  • @wave.firefreezer8390
    @wave.firefreezer8390 Год назад +2

    Amazing top video!

  • @luiscampos6064
    @luiscampos6064 2 года назад +3

    Very helpful, thanks.

  • @thechesstrain528
    @thechesstrain528 Год назад +2

    thanks , it worked for me :)

  • @madeleniflores2990
    @madeleniflores2990 3 месяца назад +2

    Thank you ❤️

  • @typalogic4454
    @typalogic4454 9 месяцев назад +1

    Thanks for the video :)

  • @truongvo920
    @truongvo920 Год назад +2

    thanks🥰

  • @imrealgigachad
    @imrealgigachad 12 дней назад +2

    Thanks man

  • @nektariis
    @nektariis Год назад +2

    Thank you🎉

  • @sefa6636
    @sefa6636 Год назад +2

    thank you man

  • @schajuli1991
    @schajuli1991 Год назад +1

    I installed the plugin but I only have a format with Redhat entry and no prettier ... - am I missing something?

    • @schajuli1991
      @schajuli1991 Год назад +1

      Actually I can set prettier as a default formatter but then it throws an error that it's not available ....

  • @zirakqader3664
    @zirakqader3664 Год назад +2

    Great one :)

  • @johnbonjovi9347
    @johnbonjovi9347 Год назад +2

    Good one! Tnx

  • @SilviuIT-tn3dn
    @SilviuIT-tn3dn Год назад +3

    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

    • @CodingWithAdam
      @CodingWithAdam  Год назад +1

      You’re welcome! The auto formatting is awesome it’s hard to code with out it. Happy the video helped! 😃

  • @abdullahsoomro6238
    @abdullahsoomro6238 Год назад +2

    Thanks alot.

  •  Год назад +1

    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

    • @CodingWithAdam
      @CodingWithAdam  Год назад +1

      Prettier is an opinionated formatter and there are not many settings. That interesting problem.

  • @andranikhambardzumyan6264
    @andranikhambardzumyan6264 10 месяцев назад +1

    Amazing video

  • @mayankgaur_
    @mayankgaur_ 8 месяцев назад +1

    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.

    • @CodingWithAdam
      @CodingWithAdam  8 месяцев назад

      Thank you for the extra tip. I must have had a few formatters installed.

  • @smurffronda2951
    @smurffronda2951 2 года назад +2

    thanks for this

  • @dambro71
    @dambro71 Год назад +2

    Is there a way so it formats without changing any quote?
    I mean ' remain '
    And " remain "

    • @CodingWithAdam
      @CodingWithAdam  Год назад +1

      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

  • @nicenavarro1376
    @nicenavarro1376 7 месяцев назад +1

    Appreciate it!

  • @Nouman-Bhai
    @Nouman-Bhai 23 дня назад +1

    My c File code is not formatted...

    • @CodingWithAdam
      @CodingWithAdam  14 дней назад +1

      Unfortunately prettier does not support c files.

  • @Nr8k
    @Nr8k Год назад +2

    Thanks gangy

  • @Titan0_7
    @Titan0_7 17 дней назад

    my prettier adds space and slash to the end of my element,
    please what can i do to fix this

  • @kiPROBRos
    @kiPROBRos 11 месяцев назад +2

    Thanks for video tutorijal, I'm subscribe, like and share. Bay.

    • @CodingWithAdam
      @CodingWithAdam  10 месяцев назад +1

      You’re welcome! Thank you for subbing liking and sharing 😁

  • @mahtab_sudip
    @mahtab_sudip Год назад +2

    Thanks

  • @soyelchicodelanus8471
    @soyelchicodelanus8471 Год назад +2

    thanks!!!

  • @krlwshu
    @krlwshu 2 года назад +2

    Thank you.

  • @ciomio3703
    @ciomio3703 Год назад +1

    my code is too narrow and looks vertical, what should i do, thanks for the video

    • @CodingWithAdam
      @CodingWithAdam  Год назад +2

      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

  • @SmithnWesson
    @SmithnWesson Год назад +1

    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".

    • @CodingWithAdam
      @CodingWithAdam  Год назад +1

      Restart vs code and then check the extensions tab to see that prettier is installed and enabled

    • @SmithnWesson
      @SmithnWesson Год назад

      Turns out that prettier will not work with Python. Must use a different formatter for Python.

    • @CodingWithAdam
      @CodingWithAdam  Год назад

      That’s right you need to use one for python. Glad you figured it out

  • @lauris5275
    @lauris5275 2 года назад +1

    I been learning js for about a year, but this extension never worked on my pc. I don't know why.

  • @rakatoneco
    @rakatoneco 2 года назад +2

    thxxxxxx very helpfullllll

  • @egm5081
    @egm5081 4 месяца назад

    thanks man!

  • @user-gt1oq6kz6o
    @user-gt1oq6kz6o 6 месяцев назад +1

    Nice Video

  • @yuukizin
    @yuukizin 2 года назад +1

    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 .

    • @CodingWithAdam
      @CodingWithAdam  2 года назад +1

      Interesting I’m not sure what that is. If I think of anything I’ll let you know.

    • @yuukizin
      @yuukizin 2 года назад +1

      @@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.

  • @TheBlackmanIsGod
    @TheBlackmanIsGod 11 месяцев назад

    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????

  • @cizario
    @cizario Год назад +1

    So we don't need .editorconfig (for indentation) ?

    • @CodingWithAdam
      @CodingWithAdam  Год назад +1

      Good question I have never used editorconfig but yes this could replace it if that is the only thing you use it for.

  • @_CryptoFunUA
    @_CryptoFunUA 9 месяцев назад +1

    thx bro

  • @Rhxrrrr
    @Rhxrrrr 4 месяца назад

    Have i told you i love you great content we should collab

  • @S.Abdul_Basit
    @S.Abdul_Basit 8 месяцев назад

    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.

  • @mailmallett
    @mailmallett 9 месяцев назад

    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

    • @CodingWithAdam
      @CodingWithAdam  9 месяцев назад

      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.

  • @MrHerrmeier
    @MrHerrmeier Год назад +1

    Does anyone know why my HTML is mostly grey and blue, even though I installed and enabled the prettier extension?

    • @CodingWithAdam
      @CodingWithAdam  Год назад +1

      Prettier will not change the colors. If you have the wrong file extension it’s possible vscode is not displaying the correct colors.

  • @Tech_Eshwar
    @Tech_Eshwar Год назад +1

    but this formatter is not working for c cpp and java

    • @CodingWithAdam
      @CodingWithAdam  Год назад +1

      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

  • @bharatbaglari
    @bharatbaglari Год назад

    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

  • @adusparx
    @adusparx 2 года назад +2

    Perfect

  • @joseeavr
    @joseeavr 2 года назад +1

    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!

    • @CodingWithAdam
      @CodingWithAdam  2 года назад +1

      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

  • @abdullakhajamohideen
    @abdullakhajamohideen 4 месяца назад +2

    nice

  • @highvid5604
    @highvid5604 Год назад +1

    Prettier not working on html file, please help

    • @CodingWithAdam
      @CodingWithAdam  Год назад +1

      Try this - Inside the html document right click and select ‘“ormat document with” then select prettier.

  • @100NPRE
    @100NPRE 8 месяцев назад

    Why my vscode does not have the option of "format with ..." when right click? Thanks.

    • @CodingWithAdam
      @CodingWithAdam  8 месяцев назад

      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.