I would like to format my HTML with a command, as I do in Visual Studio, using Ctrl+K+D. Is this possible in Atom? If not, are there other options?
6 Answers
Atom does not have a built-in command for formatting html. However, you can install the atom-beautify package to get this behavior.
- Press CTRL + SHFT + P to bring up the command palette (CMD + SHFT + P on a Mac).
- Type Install Packages to bring up the package manager.
- Type beautify into the search box.
- Choose atom-beautify or one of the other packages and click Install.
- Now you can use the default keybinding for atom-beautify CTRL + ALT + B to beautify your HTML (CTRL + OPTION + B on a Mac).
There are a few packages for prettifying HTML. You can find them by searching the Atom package archive:
- Navigate to the Atom site
- Click the Packages link
- Enter "prettify" in the search box
Or just go to this link: https://atom.io/packages/search?q=prettify
Once you've selected a package that does what you want you can install it by using the command: apm install [package name]
from the command line or install it using the interface in Preferences.
When the package is installed, follow its instructions for how to activate its capabilities.
Not Just HTML, Using atom-beautify
- Package for Atom, you can format code for HTML, CSS, JavaScript, PHP, Python, Ruby, Java, C, C++, C#, Objective-C, CoffeeScript, TypeScript, Coldfusion, SQL, and more) in Atom within a matter of seconds.
To Install the atom-beautify
package :
- Open Atom Editor.
- Press Ctrl+Shift+P (Cmd+Shift+P on mac), this will open the atom Command Palette.
- Search and click on
Install Packages & Themes
. A Install Package window comes up. - Search for
Beautify
package, you will see a lot of beautify packages. Install any. I will recommend foratom-beautify
. - Now Restart atom and TADA! now you are ready for quick formatting.
To Format text Using atom-beautify
:
- Go to the file you want to format.
- Hit Ctrl+Alt+B (Ctrl+Option+B on mac).
- Your file is formatted in seconds.