Format code command for php/html in visual studio code

:tada: Install

Search for Unibeautify extension và click Install.See Install an extension for more details.

Bạn đang xem: Format code command for php/html in visual studio code

code --install-extension Glavin001.unibeautify-vscode

:books: Support

See https://github.com/Unibeautify/vscode/blob/master/src/beautifiers.ts for danh sách of supported beautifiers.

#BeautifierDocumentation1Blackhttps://unibeautify.com/docs/beautifier-blaông xã.html2CSScombhttps://unibeautify.com/docs/beautifier-csscomb.html3ClangFormathttps://unibeautify.com/docs/beautifier-clangformat.html4ESLinthttps://unibeautify.com/docs/beautifier-eslint.html5Gofmthttps://unibeautify.com/docs/beautifier-gofmt.html6JS-Beautifyhttps://unibeautify.com/docs/beautifier-js-beautify.html7PHP-CS-Fixerhttps://unibeautify.com/docs/beautifier-php-cs-fixer.html8PHP_CodeSnifferhttps://unibeautify.com/docs/beautifier-php_codesniffer.html9Prettierhttps://unibeautify.com/docs/beautifier-prettier.html10Pretty Diffhttps://unibeautify.com/docs/beautifier-pretty-diff.html11TSLinthttps://unibeautify.com/docs/beautifier-tslint.html12YAPFhttps://unibeautify.com/docs/beautifier-yapf.html13sqlformathttps://unibeautify.com/docs/beautifier-sqlformat.html14stylelinthttps://unibeautify.com/docs/beautifier-stylelint.html

:art: Usage

:wrench: Configure

Important: You must first configure for the extension lớn work properly.

Use the Unibeautify Assistant for an interactive cài đặt of your configuration tệp tin. Simply select the languages you want & the configuration assistant will walk you though the options available. At the over, simply download or copy lớn your clipboard your configuration.

:pencil: Example Configuration File

See https://unibeautify.com/docs/config-file.html for details.

Given the following scenario:

Create a .unibeautifyrc.yml file in your project"s root directory with the following contents:

---JavaScript: # Enable language beautifiers: <"Prettier"> # Enable beautifiers indent_style: "space" indent_size: 2Then look at https://unibeautify.com/docs/beautifier-prettier.html và https://unibeautify.com/docs/options-for-languages.html for more supported options.

Xem thêm: Bé 5 Tháng Tuổi Và Những Mốc Phát Triển Đáng Kinh Ngạc, Trẻ 5 Tháng Tuổi Biết Làm Gì

:pushpin: Default configuration

We provide the option to set a path lớn a mặc định configuration tệp tin, so whenever a project of yours has no, e.g. .unibeautifyrc.yml, the mặc định configuration will be used as a fallbaông chồng.

To enable this, just add this to lớn your VSCode settings:

"unibeautify.defaultConfig": "/path/to/your/.unibeautifyrc.yml",

:zap: Keyboard Shortcut

From Stack Overflow:

Windows: Shift + Alt + FMac: Shift + Option + FUbuntu: Ctrl + Shift + I

:musical_keyboard: Commvà Palette

mở cửa the Command Palette (Ctrl +Shift+ P.. or Comm& + Shift + Phường on Mac) và search for format:

*

Format Document - Formats the entire editor document.Format Selection - Formats only the selection. Only appears when text selected.

:question: FAQ

How vày I add language tư vấn for a non-standard tệp tin extension?

This section is for you if you are seeing the following error message after running Format Document or similar:

*

See https://code.darkedeneurope.com.com/docs/languages/overview#_adding-a-file-extension-to-a-language for VSCode documentation on tệp tin.associations setting.For example, the .vscode/settings.json below adds the .myphp tệp tin extension khổng lồ the php language identifier:

"files.associations": "*.myphp": "php"

BeforeAfter
*
*
How bởi I disable a supported language?By mặc định all languages supported by Unibeautify will be enabled.

You can disable a specific language by setting the language options to false as shown below.

Important: You must restart/reload VSCode after enabling/disabling a language.

Xem thêm: Download Axes

Example .unibeautifyrc.yml:

---CSS: false # Disable CSS!JavaScript: # Enable TypeScript beautifiers: <"Prettier"> # Enable beautifiers indent_style: "space" indent_size: 2

BeforeAfter
Beautified CSS files
*
What can I do when a beautifier takes lớn much time formatting?This section is for you if you are seeing the following error message in the developer console after running Format Document or similar:

*

Sometimes beautifiers are taking much time formatting your tệp tin, this can be caused by big files or many settings you have phối for your beautifier, then you need to increase the VSCode editor.formatOnSaveTimeout option to give sầu the beautifier more time formatting your tệp tin.

Just add this entry in your VSCode settings:

"editor.formatOnSaveTimeout": 2000The time is set in milliseconds, in the example above sầu 2000 is equal lớn 2 seconds


Chuyên mục: