Marking And Highlighting

From Notepad++ Wiki
Jump to: navigation, search
How colour codes make it easier to navigate through a file, even more so for a source code file


Highlighting

Highlighting is a temporary change of background or foreground of some area of text.

When does it take place?

This is supported in four distinct situations:

  1. The selected text, if any, is highlighted. The relevant settings are on Settings -> Styler Configurator -> Global Styles , Selected text colour. Only the background colour is adjustable. It replaces whatever background colour was there. This cannot be disabled.
  2. Matching braces. The settings for selected braces are at Settings -> Styler Configurator -> Global Styles , Brace Highlight style. This cannot be disabled. When the caret is on either side of a brace, the matching brace is also highlighted. The brace being matched is left of the caret if there is an ambiguity.
  3. Current line. This is covered in Current Line Highlighting.
  4. Matching Tags highlighting. This feature is specific to the HML and XML languages. It is controlled from the Settings -> Styler Configurator -> Global Styles , Highlight matching tags frame. The facility can be toggled on or off, you can choose whether to highlight attributes, and also whether embedded code (comments, PHP, ASP) is to be highlighted as well. The appeaance settings (only the background color is adjustable) are at Settings -> Styler Configurator -> Global Styles , Tag match highlighting / Tags attribute.

More control

The following macros allow to tweak parameters which are not available through any regular user interface as of v6.6.6:

  • Use the following to enable/disable selection highlighting:
<Macro name=" hlSel " Ctrl="yes" Alt="yes" Shift="no" Key="100">
   <Action type="0" message=" 2163" wParam="0" lParam="0" sParam=""/>
</Macro>
To enable again, replace "wParam="0" " by "wParam="1" ".
  • The following enables/disables background highlighting of the selection, and sets the background color:
<Macro name=" SelBack " Ctrl="yes" Alt="yes" Shift="no" Key="100">
   <Action type="0" message=" 2067 " wParam= "1"  lParam= new_color sParam=""/>
</Macro>
new_color is a 24-bit RGB colour. To disable, replace "wParam="1" " with "wParam="0" ".
  • The following enables foreground highlighting of the selection, and sets the background color:
<Macro name=" SelFore " Ctrl="yes" Alt="yes" Shift="no" Key="100">
   <Action type="0" message=" "2068" " wParam= "1" lParam= new_color sParam=""/>
</Macro>
new_color is a 24-bit RGB colour. To disable, replace "wParam="1" " with "wParam="0" ".
  • The following sets the transparency of the selection highlighting:
<Macro name=" SelAlpha " Ctrl="yes" Alt="yes" Shift="no" Key="100">
   <Action type="0" message=" 2478 " wParam= transp_level lParam="0" sParam=""/>
</Macro>
transp_level is an integer between 0 and 2556. The igher it is, the more opaque the selection highlighting.
  • The following extends selection beyond the physical end of line:
<Macro name=" SelInfinite " Ctrl="yes" Alt="yes" Shift="no" Key="100">
   <Action type="0" message=" 2480 " wParam= "1" lParam="0" sParam=""/>
</Macro>
To disable, replace "wParam="1" = by "wParam="0" ".

Marking

Marking is a way to mark text by assigning it a more or less permanent style.

Prominent among marking schemes is syntax highlighting. It does not come and go like selection or current line highlighting, yet this is the commonly accepted name it goes by. All settings in Settings -> Styler Configurator besides those for Global Style and Search results are devoted to syntax highlighting. It cannot be disabled - this feature is the raison d'être of the Scintilla component, in the first place.

Marking of search results is covered in Searching And Replacing, so it will not be discussed here. This includes smart highlighting, another misnomer.

There is also a somehow volatile Mark All/Unmark All group of commands, which will mark all occurrences of the current selection (or word under the caret, if no selection) throughout the current document. You can select from five mark styles from the Edit -> Mark All submenu, and can selectively remove a style marking from the Edit -> Unmark All submenu. The background settings are located in Settings -> Styler Configurator -> Global Styles , Mark Style 1 through 5. These commands can be recorded in macros.
Text marked in this manner can be navigated using Search -> Jump Up or Down submenus; there are six sub-items for each command, corresponding to the five mark styles and the default Found mark style.

The shortcuts for Jump Up and Jump Down commands look the same in the Shortcut mapper, ie "1st style". The Jump Down shortcuts are at the end of the list of Main menu commands. Jump Up shortcuts are at lines 72-77 as of version 5.6.1.