Notepad++ auto indent html code while writing
Solution 1
Is there a plugin or other method to auto intent HTML while you are writing the code?
Two possibilities:
Use the TextFX plugin which has HTML Tidy built in.
Use the Indent by fold plugin (see below).
IndentByFold plug-in for Notepad++
Here's your php code indented by fold:
(The image above is not assembled from two separate images! Notepad++ has the ability to clone its tabs in a new view)
You can access here a screencast demo for the
Indent by fold
plugin. There's no separate plugin for theauto complete
feature in the video; for most languages there are defined already xml files with keywords:
Now, about the
Code Alignment
plugin: just use it only if you are not satisfied with theIndent by fold
results!
Here's how you can define a shortcut for the the indent operation:
Settings/Shortcut mapper/Plugin Commands
The
Ctr + K
andCtrl + D
shortcuts key are already "taken" (bycomment code
andduplicate selection
), therefore I've choosed another combination. But everyone can re-map all the commands according to own needs.
If anytime you find a language with a "weak"
code formatting / folding
you can take the lead, and proceed in defining your own folding and coloring rules for keywords, comments, numbers, operators and delimiters:
See how beautiful
Indent by fold
works when I pressALt + K
?The vbproc keyword is underlined because the
DSpellChecker
plugin is active.Here are a zillion UDLs (User Defined Languages) for Notepad++. To better understand how to use this feature I recommend you to read the UDL 2.0 online documentation. It was a time when folding was possible only for single words like "BeginSub" and "EndSub". Now it is easier because folding can be done using expressions, as you can see in my My better ASP example. Even now, the UDL cannot address every imaginable situations (there is a work in progress called UDL 3). But can we blame the Notepad++ developers for not achieving perfection with this free and simple, yet wonderful utility?
Source answer Auto indentation plugin for Notepad++ by Sorin Călinică
Solution 2
I don't know of something that is for Notepad++, but I strongly recommend downloading Brackets and then getting the Emmet and Beautify extensions. Emmet contains tons of great keystrokes for quickly creating html elements, and Beautify has an awesome keystroke that can auto-indent an entire page (my key binding is ctrl+shift+L , which I think is the default).
Related videos on Youtube
Mark Skelton
I'm a staff software engineer and lead developer working at Widen, an Acquia company. While I'm not afraid of CSS, my true passion lies in JavaScript engineering and developer experience (DX). I love finding ways to simplify or improve development workflow to save time and make it more fun to work on applications. Wait, did I forget to mention how much I love TypeScript? Outside of work, I'm a small town kid from Wisconsin who loves small town life almost as much as I like snow and winter. In my free time I like working on my house, spending time with my girlfriend, and playing disc golf. I am also a devout Christian seeking to be more like Jesus in word, thought, and deed. While I am a software engineer and a total nerd, I'm a huge extrovert and love spending time with people. If you ever want to debate the usefulness of college education for professions like computer science, I will gladly oblige as I am a self-taught developer who found very little practical value in college behind getting that slip of paper they call a diploma.
Updated on September 18, 2022Comments
-
Mark Skelton almost 2 years
I have seen many plugins in Notepad++ for indenting html code after you write the code, but is there a plugin or other method to auto intent html while you are writing the code? Many of the other programming languages Notepad++ supports automatically indent while you are writing but html doesn't seem to have the same support.
Any ideas?
-
DavidPostill over 8 yearsI use the TextFX plugin which has HTML Tidy built in.
-
DavidPostill over 8 years
-
DavidPostill over 8 yearsWhich option did you go for?
-
Mark Skelton over 8 yearsI went for the indent by fold plugin.
-
-
Bob over 6 yearsAlthough it was an answer for the poster, he's explicitly asking while writing. This doesn't meet that requirement. I have the same requirements and want auto indent while writing, like it does for PHP. I don't want to press a hotkey for that every time. Is there a new up-to-date solution?
-
DavidPostill over 6 years@Bob Not that I know of.