How to highlight text with color in Notepad++

Using syntax highlighting
One of the most common ways to highlight text with color in Notepad++ is by using syntax highlighting. Syntax highlighting automatically colors various code elements depending on the selected programming language.
- Open Notepad++.
- Open the file you want to edit.
- Go to the Language menu.
- Select a programming language from the list.
After selecting a programming language, Notepad++ will automatically start highlighting the syntax, highlighting keywords, comments, strings, and other elements in different colors.
Custom styles setup
If you need to highlight text that is not code, you can use custom styles.
- Go to the Settings menu.
- Select Style Configurator.
- Select the desired programming language or create a new style.
- Customize the colors and fonts as desired.
- Click Save & Close.
Using comments
Another way to highlight text with color is by using comments. In most programming languages, comments are not executed and are displayed in a different color. You can use this to temporarily highlight important parts of the code.
Example of a comment in Python:
# This is a comment
Using plugins
Notepad++ supports plugins that can significantly extend the functionality of the editor. One such plugin is NppExec, which allows you to execute scripts and commands in Notepad++.
- Go to the Plugins menu.
- Select Plugins Admin.
- Find and install NppExec.
- After installation, go to the Plugins menu, then NppExec, and select Execute....
- Write or paste the desired script and click OK.
Example of an NppExec script:
// Set background color of a line
npp_save
npp_console keep
npp_console on
// Set background color of the line to yellow
echo Setting background color to yellow
SCI_SENDMSG 2082 10 0x00FFFF00
Description of commands:
npp_save
: Save the current file.npp_console keep
: Keep the console open after executing the script.npp_console on
: Enable console output.SCI_SENDMSG
: Send a message to Scintilla. In this case, theSCI_SETSELBACK
(2082) command is used to set the background color of the selected text.10
: Style index. In this case, 10 is the selected text.0x00FFFF00
: Color in RGB format. Yellow color has a value of0x00FFFF00
.
After executing the script, the line with the selected text will be colored yellow. You can change the color by changing the value 0x00FFFF00
to another color in RGB format.
Highlighting text with color in Notepad++ is a useful feature that can significantly simplify working with code and text. Using syntax highlighting, custom styles setup, comments, and plugins, you can customize the editor for your task.