<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Can clickable links contain line numbers?]]></title><description><![CDATA[<p dir="auto">I have log files that have clickable links in them like:</p>
<pre><code>____________________________________________
(2)file:///C:/Scot/config/BaseTBAutomationPosMgr.xml#3686
</code></pre>
<p dir="auto">I can click this link and it opens the file in Notepad++ like I intended.  However, it doesn’t go to line 3686.  Is there any way I can make this link or another format link open the file in Notepad++ and go to that line?</p>
]]></description><link>https://community.notepad-plus-plus.org/topic/12888/can-clickable-links-contain-line-numbers</link><generator>RSS for Node</generator><lastBuildDate>Wed, 22 Apr 2026 08:29:35 GMT</lastBuildDate><atom:link href="https://community.notepad-plus-plus.org/topic/12888.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 09 Dec 2016 20:41:03 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Can clickable links contain line numbers? on Tue, 13 Dec 2016 18:45:35 GMT]]></title><description><![CDATA[<p dir="auto">Thank you!  The last works perfect.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/19948</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/19948</guid><dc:creator><![CDATA[David Miller229]]></dc:creator><pubDate>Tue, 13 Dec 2016 18:45:35 GMT</pubDate></item><item><title><![CDATA[Reply to Can clickable links contain line numbers? on Tue, 13 Dec 2016 04:27:21 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/7089">@David-Miller229</a></p>
<p dir="auto">ok, one last change before going to bed.<br />
Maybe there is text before and after the link, in such a case<br />
it would break the logic. Here a solution which gets the link text only.<br />
Replace callbackHOTSPOT… with this one</p>
<pre><code>def callbackHOTSPOTRELEASECLICK(args):
    __pos = args['position']
    __style_id = editor.getStyleAt(__pos)
    __word_start = None
    __word_end = None
    
    _p = __pos
    while True:
        __word_start = _p
        if editor.getStyleAt(_p) != __style_id:
            break
        _p -= 1

    _p = __pos
    while True:
        if editor.getStyleAt(_p) != __style_id:
            __word_end = _p
            break
        _p += 1
    
    link_text = editor.getTextRange(__word_start, __word_end+1) 
    
    if file_identifier in link_text and position_seperator in link_text:
        global file_to_load
        global line_in_file
        file_to_load, line_in_file = link_text[link_text.find(file_identifier):].split(position_seperator)
        file_to_load = file_to_load.replace(file_identifier, '')
        file_to_load = os.path.normpath(file_to_load)
        notepad.open(file_to_load)
</code></pre>
<p dir="auto">Good Night.</p>
<p dir="auto">Cheers<br />
Claudia</p>
]]></description><link>https://community.notepad-plus-plus.org/post/19921</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/19921</guid><dc:creator><![CDATA[Claudia Frank]]></dc:creator><pubDate>Tue, 13 Dec 2016 04:27:21 GMT</pubDate></item><item><title><![CDATA[Reply to Can clickable links contain line numbers? on Tue, 13 Dec 2016 03:29:21 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/7089">@David-Miller229</a></p>
<p dir="auto">and if your program starts counting lines from 1 instead of 0 you need to<br />
change the line</p>
<pre><code>editor.gotoLine(int(line_in_file))
</code></pre>
<p dir="auto">to</p>
<pre><code>editor.gotoLine(int(line_in_file)-1)
</code></pre>
<p dir="auto">So, hopefully this was the last update today ;-)</p>
<p dir="auto">Cheers<br />
Claudia</p>
]]></description><link>https://community.notepad-plus-plus.org/post/19920</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/19920</guid><dc:creator><![CDATA[Claudia Frank]]></dc:creator><pubDate>Tue, 13 Dec 2016 03:29:21 GMT</pubDate></item><item><title><![CDATA[Reply to Can clickable links contain line numbers? on Tue, 13 Dec 2016 03:23:06 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/7089">@David-Miller229</a></p>
<p dir="auto">ok, found the culprit, we need to use HOTSPOTRELEASECLICK instead HOTSPOTCLICK. The following should work.</p>
<pre><code>import os

file_identifier = 'file:///'
position_seperator = '#'
file_to_load = None
line_in_file = 0
 
def callbackBUFFERACTIVATED(args):
    global file_to_load
    if file_to_load is not None:
        current_file = notepad.getBufferFilename(args['bufferID'])
        if file_to_load.lower() == os.path.normpath(current_file).lower():
            editor.gotoLine(int(line_in_file))
            editor.verticalCentreCaret()
            file_to_load = None


def callbackHOTSPOTRELEASECLICK(args):
    line_of_link = editor.lineFromPosition(args['position'])
    link_text = editor.getLine(line_of_link)
    if file_identifier in link_text and position_seperator in link_text:
        global file_to_load
        global line_in_file
        file_to_load, line_in_file = link_text.split(position_seperator)
        file_to_load = file_to_load.replace(file_identifier, '')
        file_to_load = os.path.normpath(file_to_load)
        notepad.open(file_to_load)

editor.callback(callbackHOTSPOTRELEASECLICK, [SCINTILLANOTIFICATION.HOTSPOTRELEASECLICK])
notepad.callback(callbackBUFFERACTIVATED, [NOTIFICATION.BUFFERACTIVATED])
</code></pre>
<p dir="auto">Cheers<br />
Claudia</p>
]]></description><link>https://community.notepad-plus-plus.org/post/19919</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/19919</guid><dc:creator><![CDATA[Claudia Frank]]></dc:creator><pubDate>Tue, 13 Dec 2016 03:23:06 GMT</pubDate></item><item><title><![CDATA[Reply to Can clickable links contain line numbers? on Tue, 13 Dec 2016 03:06:54 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/7089">@David-Miller229</a></p>
<p dir="auto">because the latest python script version tends to fail if installed by plugin manager<br />
just double check if it has correctly installed on your side.  Plugins-&gt;PythonScript-&gt;Show Console should report something like</p>
<pre><code>Python 2.7.6-notepad++ r2 (default, Apr 21 2014, 19:26:54) [MSC v.1600 32 bit (Intel)]
Initialisation took 145ms
Ready.
</code></pre>
<p dir="auto">If this doesn’t appear or you get an error download the <a href="http://sourceforge.net/projects/npppythonscript/files/Python%20Script%201.0.8.0/PythonScript_1.0.8.0.msi/download" rel="nofollow ugc">MSI</a> package and reinstall it.</p>
<p dir="auto">Once done, create a new script by Plugin-&gt;PythonScript-New Script<br />
name the file <a href="http://startup.py" rel="nofollow ugc">startup.py</a> and paste the following content into it.</p>
<pre><code>import os

file_identifier = 'file:///'
position_seperator = '#'
file_to_load = None
line_in_file = 0
 
def callbackBUFFERACTIVATED(args):
    global file_to_load
    if file_to_load is not None:
        current_file = notepad.getBufferFilename(args['bufferID'])
        if file_to_load.lower() == os.path.normpath(current_file).lower():
            editor.gotoLine(int(line_in_file))
            editor.verticalCentreCaret()
            file_to_load = None


def callbackHOTSPOTCLICK(args):
    line_of_link = editor.lineFromPosition(args['position'])
    link_text = editor.getLine(line_of_link)
    if file_identifier in link_text and position_seperator in link_text:
        global file_to_load
        global line_in_file
        file_to_load, line_in_file = link_text.split(position_seperator)
        file_to_load = file_to_load.replace(file_identifier, '')
        file_to_load = os.path.normpath(file_to_load)
        notepad.open(file_to_load)

editor.callback(callbackHOTSPOTCLICK, [SCINTILLANOTIFICATION.HOTSPOTCLICK])
notepad.callback(callbackBUFFERACTIVATED, [NOTIFICATION.BUFFERACTIVATED])
</code></pre>
<p dir="auto">Take care about indention, python is strict about it (don’t know if you familar with python language).</p>
<p dir="auto">One additional step -&gt; Plugins-&gt;PythonScript-&gt;Configuration<br />
change Initialisation from LAZY to ATSTARTUP.</p>
<p dir="auto">Done - every time you start npp this script gets executed automatically.</p>
<p dir="auto">What does the script?<br />
It registers a callback for hotspotclick and bufferactivated notification. Once you click<br />
on a link the callback gets executed and tries to get the text from the link.<br />
If it starts with file:/// and has # in the line it is supposed to be a file link and gets<br />
the details, file_to_load and line_in_file. Then it asks notepad to open that file.<br />
If this is successful, npp sends a notification (bufferactivated) once the buffer has been loaded. Now the second part starts - it gets checked if this is the file we want<br />
and if so we goto the line in question.<br />
Currently I have no windows environment to test but under Linux(wine)<br />
I do have a strange behavior. When the goto line is called some text before that<br />
line gets selected. I hope this isn’t an issue under windows.</p>
<p dir="auto">Cheers<br />
Claudia</p>
]]></description><link>https://community.notepad-plus-plus.org/post/19917</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/19917</guid><dc:creator><![CDATA[Claudia Frank]]></dc:creator><pubDate>Tue, 13 Dec 2016 03:06:54 GMT</pubDate></item><item><title><![CDATA[Reply to Can clickable links contain line numbers? on Mon, 12 Dec 2016 21:43:46 GMT]]></title><description><![CDATA[<p dir="auto">Python would be great!  I already have it installed.  I have never used these kinds of scripts with NPP so that would be a great learning experience for me.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/19909</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/19909</guid><dc:creator><![CDATA[David Miller229]]></dc:creator><pubDate>Mon, 12 Dec 2016 21:43:46 GMT</pubDate></item><item><title><![CDATA[Reply to Can clickable links contain line numbers? on Fri, 09 Dec 2016 22:02:40 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/7089">@David-Miller229</a></p>
<p dir="auto">I don’t think it is possible using native npp functions.<br />
What I can think of is using a scripting language like python script or lua script<br />
and using the hotspotclick notification send by scintilla.<br />
We would receive the location/position of this click event and could get the text<br />
from that line. If your format is always the same I assume we could prepare such a script.<br />
Let us know if you wanna go this way.</p>
<p dir="auto">Cheers<br />
Claudia</p>
]]></description><link>https://community.notepad-plus-plus.org/post/19830</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/19830</guid><dc:creator><![CDATA[Claudia Frank]]></dc:creator><pubDate>Fri, 09 Dec 2016 22:02:40 GMT</pubDate></item></channel></rss>