Explain Codes LogoExplain Codes Logo

Formatting code in Notepad++

tools
macros
keyboard-shortcuts
code-formatting
Nikita BarsukovbyNikita Barsukov·Oct 4, 2024
TLDR

To format HTML in Notepad++, install XML Tools via Plugins Admin, then select Pretty Print (XML). That's it! Proper indentation appears automatically.

<!-- Before (like my messy room) --> <html><head></head><body><p></p></body></html> <!-- After (Mum would be proud!) --> <html> <head></head> <body> <p></p> </body> </html>

Remember, avoid ill-formed HTML as it may lead to errors.

The solution also works well for CSS and Python code. My advice? Explore TextFX or install the UniversalIndentGUI plugin for more advanced operations.

Boosting your Notepad++ set-up

UniversalIndentGUI: The secret to custom formats

Feel the current tools are still not enough? UniversalIndentGUI enhances your formatting with advanced control, supports various languages, and emulates Visual Studio's handy Ctrl+K+D function.

Keyboard shortcuts: Because who likes clicking?

Automate repetitive tasks with custom macros. Assign your formatting commands to keyboard shortcuts for quick access. Ctrl + Alt + F can trigger your favourite macro!

TextFX: Not just pretty, but powerful

TextFX's multiline editing, exclusive to Notepad++, is perfect for rearranging lengthy code at record speed. From sorting lines to white space management, say hello to an upgraded version of Ctrl+K+D experience!

Enhancing Editor Efficiency

Efficient code editing

Column mode editing (Alt+C) in Notepad++ allows precise adjustment of code blocks. Other key features include line duplication (Ctrl+D), line switching (Ctrl+Shift+Up/Down), and toggleable bookmarks for swift navigation.

Code management in a nutshell

Get an overview of your structure with collapsing and uncollapsing code levels (Alt+[, Alt+]). Hygiene matters here too, so block and stream comment (Ctrl+Q) and convert text case as needed (Ctrl+U or Ctrl+Shift+U).