Clickable Links

From Notepad++ Wiki
(Redirected from Hyperlinks)
Jump to: navigation, search
Give life to link addresses (URIs) inside documents

Notepad++ is a text editor. As such, it does not support specific actions when interacting with text in other ways than through editing commands. Optionally, and as an exception to this overall design, web addresses can be made into active links.

The Settings -> Preferences -> MISC -> Clickable Link Settings group box has two checkboxes. The upper one is meant to enable or disable the facility. When checked, the lower checkbox becomes enabled and controls whether links are shown with an underline, like most browsers do. If you change the setting during an edit session, you may need to force text being restyled for the changes to apply.

When the mouse hovers over an active link, the pointer changes to the familiar hand shape, and double clicking the link opens it in your default browser. Whether the new page is shown in a new tab or window depends on the settings of the browser.

Controlling link appearance

Even though there is no graphical interface to change link properties, Scintilla allows some degree of customisation. You can use synthetic Macros to easily define commands that perform such customisation. They are performed only if you fire them.

All clickable links share the same style, namely the style with an ID of 30. This style is changed whenever a link is encountered. This will have the perhaps counter-intuitive effect that, if a document has two links that were drawn in different styles, changing the style of one link will cause the other to adjust. Since links appear mostly as delimited strings, comments or plain text, this is a rare case anyway. Note that this style can be manipulated from the standard interface via Settings -> Styler Configurator -> Global Styles , URL hovered

To cause a style you know the ID of (by examining stylers.xml) to act as a hot spot - the name Scintilla gives to clickable links, because there could be other marginal uses for the feature -, the following macro definition can be used:

<Macro name="setAsHotSpot" Ctrl="yes" Alt="yes" Shift="no" Key="100">
   <Action type="0" message="2409" wParam=style_number lParam="1" sParam=""/>

Replace "1" with "0" to turn off.

By default, clickable links do not span across several lines. You can change this policy using

<Macro name="spillOver" Ctrl="yes" Alt="yes" Shift="no" Key="100">
   <Action type="0" message="2421" wParam="0" lParam="0" sParam=""/>

This allows multiline links. Change "0" to "1" to revert to single line links.

Whatever its appearance when not hovered upon, links get an uniform background and foreground colour when the mouse pointer is over them. The following macro definitions allow changing these colours:

<Macro name="setHotBackground" Ctrl="yes" Alt="yes" Shift="no" Key="100">
   <Action type="0" message="2411" wParam="1" lParam=your_colour sParam=""/>
<Macro name="setHotForeground" Ctrl="yes" Alt="yes" Shift="no" Key="100">
   <Action type="0" message="2410" wParam="1" lParam=your_colour sParam=""/>

In either case, as usual, your_colour is the decimal representation of a RGB colour, between double quotes. For instance, bright red is 0,0,FF, resulting in "255".

As usual, all macros listed here can have their names and keyboard bindings changed through the Shortcut Mapper.