<?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[Is there a way&#x2F;plugin that makes notepad++ run code on a file when we open it?]]></title><description><![CDATA[<p dir="auto">Is there a way/plugin that makes notepad++ run code on a file when we open it?<br />
For example: I could put some code for np++, telling it to collapse all start blocks, inside a comment so it wouldn’t affect my code?<br />
I do code in a few files with a lot of code, including functions, etc. and everytime I open those files I must collapse all those unneeded parts. Automatically saving this data about what blocks are collapsed in the file isn’t a good idea, but a plugin that helps me adding that info inside a comment, which notepad++ could still read and know what blocks should be collapsed would help a lot.<br />
Thanks.</p>
]]></description><link>https://community.notepad-plus-plus.org/topic/14153/is-there-a-way-plugin-that-makes-notepad-run-code-on-a-file-when-we-open-it</link><generator>RSS for Node</generator><lastBuildDate>Sun, 19 Jul 2026 16:29:37 GMT</lastBuildDate><atom:link href="https://community.notepad-plus-plus.org/topic/14153.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 15 Jul 2017 22:47:53 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Is there a way&#x2F;plugin that makes notepad++ run code on a file when we open it? on Sun, 23 Jul 2017 15:17:58 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/claudia-frank" aria-label="Profile: Claudia-Frank">@<bdi>Claudia-Frank</bdi></a> said:</p>
<blockquote>
<p dir="auto">just for clarification, you are happy? No further modification needed?</p>
</blockquote>
<p dir="auto">Yeah, it looks good enough. Ty.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/25830</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/25830</guid><dc:creator><![CDATA[Alguem Meugla]]></dc:creator><pubDate>Sun, 23 Jul 2017 15:17:58 GMT</pubDate></item><item><title><![CDATA[Reply to Is there a way&#x2F;plugin that makes notepad++ run code on a file when we open it? on Sun, 23 Jul 2017 15:03:53 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/alguem-meugla" aria-label="Profile: Alguem-Meugla">@<bdi>Alguem-Meugla</bdi></a></p>
<p dir="auto">just for clarification, you are happy? No further modification needed?</p>
<p dir="auto">Cheers<br />
Claudia</p>
]]></description><link>https://community.notepad-plus-plus.org/post/25829</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/25829</guid><dc:creator><![CDATA[Claudia Frank]]></dc:creator><pubDate>Sun, 23 Jul 2017 15:03:53 GMT</pubDate></item><item><title><![CDATA[Reply to Is there a way&#x2F;plugin that makes notepad++ run code on a file when we open it? on Sun, 23 Jul 2017 14:54:29 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/claudia-frank" aria-label="Profile: Claudia-Frank">@<bdi>Claudia-Frank</bdi></a><br />
Oh I though <strong>NPP_COLLAPSE(19,41)</strong> was going only to collapse lines 19 and 41, but instead it collapse lines 19 to 41… Thank you anyway. This script is very helpful.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/25828</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/25828</guid><dc:creator><![CDATA[Alguem Meugla]]></dc:creator><pubDate>Sun, 23 Jul 2017 14:54:29 GMT</pubDate></item><item><title><![CDATA[Reply to Is there a way&#x2F;plugin that makes notepad++ run code on a file when we open it? on Sun, 23 Jul 2017 14:43:54 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/alguem-meugla" aria-label="Profile: Alguem-Meugla">@<bdi>Alguem-Meugla</bdi></a></p>
<p dir="auto">Yes, slightly different regex and for loop can do this but we need to define the cases.</p>
<p dir="auto">Is a list ALWAYS a pair of fold <strong>from</strong> line <strong>to</strong> line triggers?<br />
Or is a list with more than two entries ALWAYS fold this line for each item<br />
and a list with 2 entries a <strong>from … to …</strong><br />
Or …</p>
<p dir="auto">Btw, may last post about logic error was not a logic issue.<br />
Looks like the initial start of npp doesn’t trigger a bufferactivated callback<br />
or python script hasn’t been started at that time to catch this notification.<br />
I already changed that and will be included in next version.</p>
<p dir="auto">Cheers<br />
Claudia</p>
]]></description><link>https://community.notepad-plus-plus.org/post/25826</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/25826</guid><dc:creator><![CDATA[Claudia Frank]]></dc:creator><pubDate>Sun, 23 Jul 2017 14:43:54 GMT</pubDate></item><item><title><![CDATA[Reply to Is there a way&#x2F;plugin that makes notepad++ run code on a file when we open it? on Sun, 23 Jul 2017 12:21:05 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/claudia-frank" aria-label="Profile: Claudia-Frank">@<bdi>Claudia-Frank</bdi></a><br />
Thank you a lot for your help.<br />
Could it also be possible to put inside the brackets <strong>NPP_COLLAPSE(19,41)</strong> how many numbers I ask it for? eg: <strong>NPP_COLLAPSE(19,22,28,35,43,54,60,67,89,139,220,…)</strong>. It actually only works for 2 line numbers. It’s ok if you don’t want to do it, I can keep using NPP_COLLAPSE_IT everywhere. Thank you!</p>
]]></description><link>https://community.notepad-plus-plus.org/post/25824</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/25824</guid><dc:creator><![CDATA[Alguem Meugla]]></dc:creator><pubDate>Sun, 23 Jul 2017 12:21:05 GMT</pubDate></item><item><title><![CDATA[Reply to Is there a way&#x2F;plugin that makes notepad++ run code on a file when we open it? on Sun, 23 Jul 2017 00:29:42 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/alguem-meugla" aria-label="Profile: Alguem-Meugla">@<bdi>Alguem-Meugla</bdi></a></p>
<p dir="auto">ok, logic error, change the line</p>
<pre><code>should_be_folded = False
</code></pre>
<p dir="auto">to</p>
<pre><code>should_be_folded = True
</code></pre>
<p dir="auto">It is the line which is directly before</p>
<pre><code>def callback_FOLD_BUFFERACTIVATED(args):
</code></pre>
<p dir="auto">But only this line.</p>
<p dir="auto">But I’m still confused that your user <a href="http://startup.py" rel="nofollow ugc">startup.py</a> doesn’t work but at least you<br />
have it working now.</p>
<p dir="auto">Cheers<br />
Claudia</p>
]]></description><link>https://community.notepad-plus-plus.org/post/25822</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/25822</guid><dc:creator><![CDATA[Claudia Frank]]></dc:creator><pubDate>Sun, 23 Jul 2017 00:29:42 GMT</pubDate></item><item><title><![CDATA[Reply to Is there a way&#x2F;plugin that makes notepad++ run code on a file when we open it? on Sun, 23 Jul 2017 00:08:27 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/claudia-frank" aria-label="Profile: Claudia-Frank">@<bdi>Claudia-Frank</bdi></a><br />
I appended the script (below) to the end of the default <a href="http://startup.py" rel="nofollow ugc">startup.py</a></p>
<pre><code>import os

# ---------------------------- configuration area -----------------------------

FILE_EXTENSION_LIST = ['.html','.js']
COLLPASE_LINE_IDENTIFIER = 'NPP_COLLAPSE_IT'
COLLPASE_FROM_TO_IDENTIFIER = 'NPP_COLLAPSE\((\d+,\d+)\)'

# -----------------------------------------------------------------------------


def scan(number_of_lines):

    def find_line_identifiers(): # NPP_COLLAPSE_IT
        matches = []
        editor.research('\\b{0}\\b'.format(COLLPASE_LINE_IDENTIFIER), lambda m: matches.append(m.span()), 0)   
        return matches

    def find_from_to_line_identifiers(): # NPP_COLLAPSE(19,41)
        matches = []
        editor.research(COLLPASE_FROM_TO_IDENTIFIER, lambda m: matches.append(m.span(1)), 0)   
        return matches
        
    for match in find_line_identifiers():
        _line = editor.lineFromPosition(match[0])
        if editor.getFoldLevel(_line) &amp; FOLDLEVEL.HEADERFLAG:
            editor.foldLine(_line,0)

    for match in find_from_to_line_identifiers():
        start_line, end_line = map(lambda x: int(x)-1, editor.getTextRange(*match).split(','))
        while True:
            if start_line &lt;= end_line:
                if editor.getFoldLevel(start_line) &amp; FOLDLEVEL.HEADERFLAG:
                    editor.foldLine(start_line,0)
                    start_line = editor.getLastChild(start_line,-1) + 1
                else:
                    start_line += 1
            else:
                break 

should_be_folded = False
def callback_FOLD_BUFFERACTIVATED(args):
    console.write('callback_FOLD_BUFFERACTIVATED\n')
    global should_be_folded
    _state = editor.getProperty('AUTO_FOLDED')
    if _state == '':
        filename, extension = os.path.splitext(notepad.getBufferFilename(args['bufferID']))
        if extension in FILE_EXTENSION_LIST:
            editor.setProperty('AUTO_FOLDED', '1')
            should_be_folded = True
        else:
            editor.setProperty('AUTO_FOLDED', '-1')
            should_be_folded = False
    else:
        should_be_folded = False

def callback_FOLD_UPDATEUI(args):
    global should_be_folded
    if should_be_folded:
        scan(editor.getLineCount())
        should_be_folded = False

notepad.callback(callback_FOLD_BUFFERACTIVATED, [NOTIFICATION.BUFFERACTIVATED])
editor.callback(callback_FOLD_UPDATEUI, [SCINTILLANOTIFICATION.UPDATEUI])

console.write('hello'))
</code></pre>
<p dir="auto">Note the last line which I added. When I open my html file the console output is:</p>
<p dir="auto"><strong>helloPython 2.7.6-notepad++ r2 (default, Apr 21 2014, 19:26:54) [MSC v.1600 32 bit (Intel)]<br />
Initialisation took 204ms<br />
Ready.</strong></p>
<p dir="auto">and the lines don’t collapse. When I open another html file, it ouputs <strong>callback_FOLD_BUFFERACTIVATED</strong> and its lines are collapsed. Switching back to the first file, the same happens (working!!!). But it still doesn’t work right at startup.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/25821</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/25821</guid><dc:creator><![CDATA[Alguem Meugla]]></dc:creator><pubDate>Sun, 23 Jul 2017 00:08:27 GMT</pubDate></item><item><title><![CDATA[Reply to Is there a way&#x2F;plugin that makes notepad++ run code on a file when we open it? on Sat, 22 Jul 2017 23:45:55 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/claudia-frank" aria-label="Profile: Claudia-Frank">@<bdi>Claudia-Frank</bdi></a><br />
I tried to reinstall Python Script using the package you linked above, and New Script still opens the same folder and the script still doesn’t work at startup.<br />
One thing to note is that when I go to Python Script configuration it shows <a href="http://startup.py" rel="nofollow ugc">startup.py</a> as a User script:<br />
<img src="https://image.prntscr.com/image/u2NQ8QcDReirUG7aPIJc0w.png" alt="" class=" img-fluid img-markdown" /><br />
Adding it to Menu items makes it show at <strong>Plugins&gt;Python Script&gt; <a href="http://startup.py" rel="nofollow ugc">startup.py</a></strong>.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/25820</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/25820</guid><dc:creator><![CDATA[Alguem Meugla]]></dc:creator><pubDate>Sat, 22 Jul 2017 23:45:55 GMT</pubDate></item><item><title><![CDATA[Reply to Is there a way&#x2F;plugin that makes notepad++ run code on a file when we open it? on Sat, 22 Jul 2017 18:23:38 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/alguem-meugla" aria-label="Profile: Alguem-Meugla">@<bdi>Alguem-Meugla</bdi></a></p>
<blockquote>
<p dir="auto">What’s your windows version?</p>
</blockquote>
<p dir="auto">Since a couple of month I use linux exclusively.<br />
Npp is started via windows emulation software WINE.<br />
But in the past I was using Windows XP and Windows 7 and I thought<br />
%APPDATA% redirected to “Application Data” like within wine,<br />
maybe I have false memory.</p>
<p dir="auto">Yes, 1.0.8 is the version I use as well.<br />
As mentioned earlier, don’t replace the default <a href="http://startup.py" rel="nofollow ugc">startup.py</a> as it contains<br />
needed code for plugin script itself.</p>
<p dir="auto">If you can’t get a user <a href="http://startup.py" rel="nofollow ugc">startup.py</a> to work, append the posted script<br />
to the end of the default <a href="http://startup.py" rel="nofollow ugc">startup.py</a> - then it has to work - I hope.</p>
<p dir="auto">Cheers<br />
Claudia</p>
]]></description><link>https://community.notepad-plus-plus.org/post/25816</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/25816</guid><dc:creator><![CDATA[Claudia Frank]]></dc:creator><pubDate>Sat, 22 Jul 2017 18:23:38 GMT</pubDate></item><item><title><![CDATA[Reply to Is there a way&#x2F;plugin that makes notepad++ run code on a file when we open it? on Sat, 22 Jul 2017 17:49:33 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/claudia-frank" aria-label="Profile: Claudia-Frank">@<bdi>Claudia-Frank</bdi></a> said:</p>
<blockquote>
<p dir="auto">In addition,</p>
<p dir="auto">C:\Users\Alguem\<strong>AppData\Roaming</strong>\Notepad++\plugins\Config\PythonScript\scripts</p>
<p dir="auto">how could this be, mine is pointing to</p>
<p dir="auto">C:\users\linus\<strong>Application Data</strong>\Notepad++\plugins\Config\PythonScript\scripts</p>
<p dir="auto">Has this changed with windows 10??</p>
</blockquote>
<p dir="auto">Isn’t Application Data the same as AppData?<br />
And %APPDATA% always redirected me to \AppData\Roaming.<br />
What’s your windows version?</p>
<blockquote>
<p dir="auto">May I ask how you installed python script?<br />
Using plugin manager or the msi package I pointed to?</p>
</blockquote>
<p dir="auto">I used Plugin Manager both times, before and after I replaced the default <a href="http://startup.py" rel="nofollow ugc">startup.py</a>, when I had to reinstall it.<br />
I will try reinstalling it using that package. Plugin manager usually works right and is very simple for me.</p>
<blockquote>
<p dir="auto">Which python script version did you install?</p>
</blockquote>
<p dir="auto">It says 1.0.8.</p>
<blockquote>
<p dir="auto">When you press CTRL+R, the windows run command should open, and type<br />
%APPDATA% and press enter, which directory gets opened and does it contain<br />
a subdirectory notepad++??</p>
</blockquote>
<p dir="auto">CTRL+R reloads the page…<br />
I can use WINDOWSKEY+R instead, which opens the Run window, or I can use the search menu on Windows 10. Typing <strong>%APPDATA%</strong> both opens <strong>…\AppData\Roaming\</strong>.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/25814</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/25814</guid><dc:creator><![CDATA[Alguem Meugla]]></dc:creator><pubDate>Sat, 22 Jul 2017 17:49:33 GMT</pubDate></item><item><title><![CDATA[Reply to Is there a way&#x2F;plugin that makes notepad++ run code on a file when we open it? on Fri, 21 Jul 2017 22:40:33 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/alguem-meugla" aria-label="Profile: Alguem-Meugla">@<bdi>Alguem-Meugla</bdi></a></p>
<p dir="auto">ok, so the reason why it doesn’t work is that python script plugin<br />
doesn’t find the <a href="http://startup.py" rel="nofollow ugc">startup.py</a> but why…</p>
<p dir="auto">Another thing which is strange, whenever I use <strong>New Script</strong><br />
it redirects to the user scripts directory, regardless if I created<br />
script in another subdirectory, totally different directory or not.<br />
Maybe this is a coincident because it can’t find the user script directory.</p>
<p dir="auto">In addition,</p>
<p dir="auto">C:\Users\Alguem\<strong>AppData\Roaming</strong>\Notepad++\plugins\Config\PythonScript\scripts</p>
<p dir="auto">how could this be, mine is pointing to</p>
<p dir="auto">C:\users\linus\<strong>Application Data</strong>\Notepad++\plugins\Config\PythonScript\scripts</p>
<p dir="auto">Has this changed with windows 10??<br />
May I ask how you installed python script?<br />
Using plugin manager or the msi package I pointed to?<br />
Which python script version did you install?<br />
Did you somehow redirect your %APPDATA% environment variable?</p>
<p dir="auto">When you press CTRL+R, the windows run command should open, and type<br />
%APPDATA% and press enter, which directory gets opened and does it contain<br />
a subdirectory notepad++??</p>
<p dir="auto">Cheers<br />
Claudia</p>
]]></description><link>https://community.notepad-plus-plus.org/post/25799</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/25799</guid><dc:creator><![CDATA[Claudia Frank]]></dc:creator><pubDate>Fri, 21 Jul 2017 22:40:33 GMT</pubDate></item><item><title><![CDATA[Reply to Is there a way&#x2F;plugin that makes notepad++ run code on a file when we open it? on Fri, 21 Jul 2017 18:30:23 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/claudia-frank" aria-label="Profile: Claudia-Frank">@<bdi>Claudia-Frank</bdi></a> said:</p>
<blockquote>
<p dir="auto">this means, that notepad++ configuration files and plugin directories are located under</p>
<p dir="auto"><em><strong>%APPDATA%\Notepad++</strong></em></p>
<p dir="auto">therefore, if you use <strong>Plugins-&gt;Python Script-&gt;New Script</strong> the script gets created in</p>
<p dir="auto"><strong>%APPDATA%\Notepad++\plugins\config\PythonScript\scripts</strong></p>
<p dir="auto">As there is no <a href="http://startup.py" rel="nofollow ugc">startup.py</a> in this directory per default you can create it and it should appear<br />
in the same level as the standard <a href="http://startup.py" rel="nofollow ugc">startup.py</a> but with the addition of (User) (done by Python Script plugin).</p>
<p dir="auto"><img src="http://i.imgur.com/2kCb5ua.png" alt="" class=" img-fluid img-markdown" /></p>
</blockquote>
<p dir="auto">New Script takes me to the last place I left the dialog on:<br />
<img src="http://html-js.comxa.com/temporary/showing_new_script.gif" alt="gif not avaiable" class=" img-fluid img-markdown" /></p>
<p dir="auto">And I don’t have a <a href="http://startup.py" rel="nofollow ugc">startup.py</a> (User) on the Scripts menu, while there’s one at <strong>%APPDATA%\Notepad++\plugins\config\PythonScript\scripts</strong>:<br />
<img src="https://image.prntscr.com/image/2uA4fCXfTVO3beReQ1nO6A.png" alt="image not avaiable" class=" img-fluid img-markdown" /></p>
<blockquote>
<p dir="auto">Please enter the following commands in the python console and post the ouput</p>
<pre><code>import sys
print '\n'.join(sys.path)
</code></pre>
</blockquote>
<p dir="auto"><strong>C:\Program Files (x86)\Notepad++\plugins\PythonScript\lib<br />
C:\Users\Alguem\AppData\Roaming\Notepad++\plugins\Config\PythonScript\lib<br />
C:\Program Files (x86)\Notepad++\plugins\PythonScript\scripts<br />
C:\Users\Alguem\AppData\Roaming\Notepad++\plugins\Config\PythonScript\scripts<br />
C:\Program Files (x86)\Notepad++\plugins\PythonScript\lib\lib-tk<br />
C:\Program Files (x86)\Notepad++\python27.zip<br />
C:\Program Files (x86)\Notepad++\DLLs<br />
C:\Program Files (x86)\Notepad++\lib<br />
C:\Program Files (x86)\Notepad++\lib\plat-win<br />
C:\Program Files (x86)\Notepad++\lib\lib-tk<br />
C:\Program Files (x86)\Notepad++</strong></p>
]]></description><link>https://community.notepad-plus-plus.org/post/25793</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/25793</guid><dc:creator><![CDATA[Alguem Meugla]]></dc:creator><pubDate>Fri, 21 Jul 2017 18:30:23 GMT</pubDate></item><item><title><![CDATA[Reply to Is there a way&#x2F;plugin that makes notepad++ run code on a file when we open it? on Thu, 20 Jul 2017 18:22:37 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/alguem-meugla" aria-label="Profile: Alguem-Meugla">@<bdi>Alguem-Meugla</bdi></a></p>
<blockquote>
<p dir="auto">Should it appear there as a second <a href="http://startup.py" rel="nofollow ugc">startup.py</a> because of this?</p>
</blockquote>
<p dir="auto">Yes, because your installation shows</p>
<p dir="auto"><strong>Local Conf mode : OFF</strong></p>
<p dir="auto">this means, that notepad++ configuration files and plugin directories are located under</p>
<p dir="auto"><em><strong>%APPDATA%\Notepad++</strong></em></p>
<p dir="auto">therefore, if you use <strong>Plugins-&gt;Python Script-&gt;New Script</strong> the script gets created in</p>
<p dir="auto"><strong>%APPDATA%\Notepad++\plugins\config\PythonScript\scripts</strong></p>
<p dir="auto">As there is no <a href="http://startup.py" rel="nofollow ugc">startup.py</a> in this directory per default you can create it and it should appear<br />
in the same level as the standard <a href="http://startup.py" rel="nofollow ugc">startup.py</a> but with the addition of (User) (done by Python Script plugin).</p>
<p dir="auto"><img src="http://i.imgur.com/2kCb5ua.png" alt="" class=" img-fluid img-markdown" /></p>
<p dir="auto">Please enter the following commands in the python console and post the ouput</p>
<pre><code>import sys
print '\n'.join(sys.path)
</code></pre>
<p dir="auto">Cheers<br />
Claudia</p>
]]></description><link>https://community.notepad-plus-plus.org/post/25750</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/25750</guid><dc:creator><![CDATA[Claudia Frank]]></dc:creator><pubDate>Thu, 20 Jul 2017 18:22:37 GMT</pubDate></item><item><title><![CDATA[Reply to Is there a way&#x2F;plugin that makes notepad++ run code on a file when we open it? on Thu, 20 Jul 2017 17:35:00 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/claudia-frank" aria-label="Profile: Claudia-Frank">@<bdi>Claudia-Frank</bdi></a> said:</p>
<blockquote>
<p dir="auto">Looks ok - do you see two <a href="http://startup.py" rel="nofollow ugc">startup.py</a> if you<br />
goto <strong>Plugins-&gt;Python Script-&gt;Scripts</strong> ?</p>
</blockquote>
<p dir="auto">There’s only one at <strong>Plugins-&gt;Python Script-&gt;Scripts</strong>, the default <a href="http://startup.py" rel="nofollow ugc">startup.py</a>. I can only add the new <a href="http://startup.py" rel="nofollow ugc">startup.py</a> if I create a new folder like Samples or I put it inside the Samples folder:<br />
<img src="https://image.prntscr.com/image/NUqzXNEERWiC0AdtCONMTA.png" alt="image" class=" img-fluid img-markdown" /></p>
<p dir="auto">I also have one new <a href="http://startup.py" rel="nofollow ugc">startup.py</a> at %APPDATA%\Notepad++\plugins\config\PythonScript\scripts\startup.py and more at MyDocuments…<br />
Should it appear there as a second <a href="http://startup.py" rel="nofollow ugc">startup.py</a> because of this?</p>
<blockquote>
<p dir="auto">Restart npp.</p>
<p dir="auto">Now, every time you switch a tab you should see the line</p>
<p dir="auto">callback_FOLD_BUFFERACTIVATED<br />
written to the console - to prove if the script runs at all.</p>
</blockquote>
<p dir="auto">The console outputs nothing when I switch tab, neither when I click the script (the blue <a href="http://startup.py" rel="nofollow ugc">startup.py</a> above in the image).</p>
]]></description><link>https://community.notepad-plus-plus.org/post/25749</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/25749</guid><dc:creator><![CDATA[Alguem Meugla]]></dc:creator><pubDate>Thu, 20 Jul 2017 17:35:00 GMT</pubDate></item><item><title><![CDATA[Reply to Is there a way&#x2F;plugin that makes notepad++ run code on a file when we open it? on Wed, 19 Jul 2017 21:41:24 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/alguem-meugla" aria-label="Profile: Alguem-Meugla">@<bdi>Alguem-Meugla</bdi></a></p>
<p dir="auto">Looks ok - do you see two <a href="http://startup.py" rel="nofollow ugc">startup.py</a> if you<br />
goto <strong>Plugins-&gt;Python Script-&gt;Scripts</strong> ?</p>
<p dir="auto">One should have the addition (User).</p>
<p dir="auto">If you press the CTRL key while clicking onto the user <a href="http://startup.py" rel="nofollow ugc">startup.py</a> it should open as a document.</p>
<p dir="auto">If this is the case, add the following line under the bufferactivated callback.</p>
<pre><code>console.write('callback_FOLD_BUFFERACTIVATED\n')
</code></pre>
<p dir="auto">Should look like</p>
<pre><code>def callback_FOLD_BUFFERACTIVATED(args):
    console.write('callback_FOLD_BUFFERACTIVATED\n')
    global should_be_folded
    _state = editor.getProperty('AUTO_FOLDED')
    if _state == '':
        filename, extension = os.path.splitext(notepad.getBufferFilename(args['bufferID']))
        if extension in FILE_EXTENSION_LIST:
            editor.setProperty('AUTO_FOLDED', '1')
            should_be_folded = True
        else:
            editor.setProperty('AUTO_FOLDED', '-1')
            should_be_folded = False
    else:
        should_be_folded = False
</code></pre>
<p dir="auto">Restart npp.</p>
<p dir="auto">Now, every time you switch a tab you should see the line</p>
<pre><code>callback_FOLD_BUFFERACTIVATED
</code></pre>
<p dir="auto">written to the console - to prove if the script runs at all.</p>
<p dir="auto">Cheers<br />
Claudia</p>
]]></description><link>https://community.notepad-plus-plus.org/post/25730</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/25730</guid><dc:creator><![CDATA[Claudia Frank]]></dc:creator><pubDate>Wed, 19 Jul 2017 21:41:24 GMT</pubDate></item><item><title><![CDATA[Reply to Is there a way&#x2F;plugin that makes notepad++ run code on a file when we open it? on Wed, 19 Jul 2017 21:28:25 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/claudia-frank" aria-label="Profile: Claudia-Frank">@<bdi>Claudia-Frank</bdi></a> said:</p>
<blockquote>
<p dir="auto">Concerning the print statement - a standard python script installation has has the following<br />
entry in the <strong>standard</strong> <a href="http://startup.py" rel="nofollow ugc">startup.py</a></p>
<p dir="auto">sys.stdout = <em><strong>editor</strong></em></p>
<p dir="auto">This means, that a print … will not be send to the console but to the currently active document.<br />
In order to change this behavior you need to modify it like this</p>
<p dir="auto">sys.stdout = <strong>console</strong></p>
<p dir="auto">and restart npp. Now a print statement would be send to console.</p>
</blockquote>
<p dir="auto">I don’t know python (i only learnt the first lessons of it on codecademy), so I didn’t know if print was supposed to write on the console or in the file. First I thought it was on the console so I was always opening it to see if there was something. But when I tested the script on the same folder as the Samples and the default <a href="http://startup.py" rel="nofollow ugc">startup.py</a> I found it was printing in the file. Not a problem. I have always checked in both places for the print output.</p>
<blockquote>
<p dir="auto">In addition, there should be a file %APPDATA%\Notepad++\plugins\config\PythonScriptStartup.cnf.</p>
<p dir="auto">Can you post its content?</p>
</blockquote>
<p dir="auto"><img src="https://image.prntscr.com/image/rr0VXJEKQ7CjKxs_rMN46Q.png" alt="SETTING/PREFERINSTALLEDPYTHON/0 and on the next line
SETTING/STARTUP/ATSTARTUP" class=" img-fluid img-markdown" /></p>
]]></description><link>https://community.notepad-plus-plus.org/post/25729</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/25729</guid><dc:creator><![CDATA[Alguem Meugla]]></dc:creator><pubDate>Wed, 19 Jul 2017 21:28:25 GMT</pubDate></item><item><title><![CDATA[Reply to Is there a way&#x2F;plugin that makes notepad++ run code on a file when we open it? on Wed, 19 Jul 2017 21:14:09 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/alguem-meugla" aria-label="Profile: Alguem-Meugla">@<bdi>Alguem-Meugla</bdi></a></p>
<p dir="auto">Ok, the command was to see if the python script plugin works in general and<br />
the debug info shows, that two directories are of interest in regards to automated startup.</p>
<p dir="auto">The <strong>standard</strong> <a href="http://startup.py" rel="nofollow ugc">startup.py</a>, the one which is automatically created during installation<br />
should be located under C:\Program Files (x86)\Notepad++\plugins\PythonScript\scripts\</p>
<p dir="auto">The <strong>user</strong> <a href="http://startup.py" rel="nofollow ugc">startup.py</a>, the one you should have created should be located under<br />
%APPDATA%\Notepad++\plugins\config\PythonScript\scripts</p>
<p dir="auto">Concerning the print statement - a standard python script installation has has the following<br />
entry in the <strong>standard</strong> <a href="http://startup.py" rel="nofollow ugc">startup.py</a></p>
<p dir="auto">sys.stdout = <em><strong>editor</strong></em></p>
<p dir="auto">This means, that a print … will not be send to the console but to the currently active document.<br />
In order to change this behavior you need to modify it like this</p>
<p dir="auto">sys.stdout = <strong>console</strong></p>
<p dir="auto">and restart npp. Now a print statement would be send to console.</p>
<p dir="auto">In addition, there should be a file %APPDATA%\Notepad++\plugins\config\PythonScriptStartup.cnf.</p>
<p dir="auto">Can you post its content?</p>
<p dir="auto">Cheers<br />
Claudia</p>
]]></description><link>https://community.notepad-plus-plus.org/post/25728</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/25728</guid><dc:creator><![CDATA[Claudia Frank]]></dc:creator><pubDate>Wed, 19 Jul 2017 21:14:09 GMT</pubDate></item><item><title><![CDATA[Reply to Is there a way&#x2F;plugin that makes notepad++ run code on a file when we open it? on Wed, 19 Jul 2017 20:54:40 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/claudia-frank" aria-label="Profile: Claudia-Frank">@<bdi>Claudia-Frank</bdi></a> said:</p>
<blockquote>
<p dir="auto">Can you post your debug-&gt;info (available under ? menu?</p>
</blockquote>
<p dir="auto">Here it is:<br />
<strong>Notepad++ v7.4.2   (32-bit)<br />
Build time : Jun 18 2017 - 23:34:19<br />
Path : C:\Program Files (x86)\Notepad++\notepad++.exe<br />
Admin mode : OFF<br />
Local Conf mode : OFF<br />
OS : Windows 10 (64-bit)<br />
Plugins : JSMinNPP.dll mimeTools.dll NppConverter.dll NppExec.dll NppExport.dll NppFTP.dll NppTextFX.dll PluginManager.dll PythonScript.dll ReloadButton.dll</strong></p>
<blockquote>
<p dir="auto">In addition, what do you see if you run the following code</p>
<p dir="auto">notepad.getVersion()</p>
<p dir="auto">in the python script console, like here</p>
</blockquote>
<p dir="auto">It returns:<br />
<strong>(7, 4, 2)</strong></p>
<p dir="auto">Definitely version 7.4.2.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/25727</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/25727</guid><dc:creator><![CDATA[Alguem Meugla]]></dc:creator><pubDate>Wed, 19 Jul 2017 20:54:40 GMT</pubDate></item><item><title><![CDATA[Reply to Is there a way&#x2F;plugin that makes notepad++ run code on a file when we open it? on Wed, 19 Jul 2017 20:00:47 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/alguem-meugla" aria-label="Profile: Alguem-Meugla">@<bdi>Alguem-Meugla</bdi></a></p>
<p dir="auto">Can you post your debug-&gt;info (available under ? menu?</p>
<p dir="auto">In addition, what do you see if you run the following code</p>
<p dir="auto">notepad.getVersion()</p>
<p dir="auto">in the python script console, like here</p>
<p dir="auto"><img src="http://i.imgur.com/LMd0TQO.png" alt="" class=" img-fluid img-markdown" /></p>
<p dir="auto">Cheers<br />
Claudia</p>
]]></description><link>https://community.notepad-plus-plus.org/post/25724</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/25724</guid><dc:creator><![CDATA[Claudia Frank]]></dc:creator><pubDate>Wed, 19 Jul 2017 20:00:47 GMT</pubDate></item><item><title><![CDATA[Reply to Is there a way&#x2F;plugin that makes notepad++ run code on a file when we open it? on Wed, 19 Jul 2017 19:33:05 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/claudia-frank" aria-label="Profile: Claudia-Frank">@<bdi>Claudia-Frank</bdi></a> said:</p>
<blockquote>
<p dir="auto">yes, you should save it in the default directory, the one which<br />
get opened by using New Script.</p>
</blockquote>
<p dir="auto">I think that there is not a place which any plugin/program can trust. When I use New Script it opens to me the directory I left the dialog on the last time, MyDocuments\Python Notepad++ (the folder I created).</p>
<p dir="auto">After reinstalling the plugin and having the default <a href="http://startip.py" rel="nofollow ugc">startip.py</a> back, I tried having a copy of the new <a href="http://startup.py" rel="nofollow ugc">startup.py</a> on MyDocuments, another on MyDocuments\Python Notepad++, and another on %APPDATA%\Notepad++\plugins\config\PythonScript\scripts (the plugin’s Help said it was the User directory). All those copys should also print some words after your script. After restarting N++ it doesn’t print anything neither collapse the line it should (<a href="https://image.prntscr.com/image/Wa9pMODERIm7Kq7cnHhZAg.png" rel="nofollow ugc">https://image.prntscr.com/image/Wa9pMODERIm7Kq7cnHhZAg.png</a>).</p>
<p dir="auto">I also tried having one copy on the same folder as the Samples folder and the default <a href="http://startup.py" rel="nofollow ugc">startup.py</a>  (inside a folder I created so it didn’t have problems with 2 <a href="http://startup.py" rel="nofollow ugc">startup.py</a>’s). After restarting N++ nothing happened, but it was appearing on the Scripts list so I clicked it and: no collapse and the print worked (this means the script is not collapsing for some reason, maybe because it’s not happening at startup?).</p>
<p dir="auto">Thank you for the help and time you are giving to this.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/25723</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/25723</guid><dc:creator><![CDATA[Alguem Meugla]]></dc:creator><pubDate>Wed, 19 Jul 2017 19:33:05 GMT</pubDate></item><item><title><![CDATA[Reply to Is there a way&#x2F;plugin that makes notepad++ run code on a file when we open it? on Tue, 18 Jul 2017 20:16:11 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/alguem-meugla" aria-label="Profile: Alguem-Meugla">@<bdi>Alguem-Meugla</bdi></a></p>
<p dir="auto">yes, you should save it in the default directory, the one which<br />
get opened by using New Script.</p>
<p dir="auto">The standard <a href="http://startup.py" rel="nofollow ugc">startup.py</a> is used do the general setups and initialization.<br />
I do not recommend to modify this file as long as you know what you do.<br />
I hope you do have a copy of the old one and you can revert your changes.<br />
If not, a reinstall of the python script plugin is needed I guess.</p>
<p dir="auto">Cheers<br />
Claudia</p>
]]></description><link>https://community.notepad-plus-plus.org/post/25697</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/25697</guid><dc:creator><![CDATA[Claudia Frank]]></dc:creator><pubDate>Tue, 18 Jul 2017 20:16:11 GMT</pubDate></item><item><title><![CDATA[Reply to Is there a way&#x2F;plugin that makes notepad++ run code on a file when we open it? on Tue, 18 Jul 2017 20:10:22 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/claudia-frank" aria-label="Profile: Claudia-Frank">@<bdi>Claudia-Frank</bdi></a> said:</p>
<blockquote>
<p dir="auto">you should have done</p>
<p dir="auto">goto <strong>Plugins-&gt;Python Script-&gt;New Script</strong> and name it <strong><a href="http://startup.py" rel="nofollow ugc">startup.py</a></strong><br />
and press Save button.<br />
Copy the posted script into the newly created document, save it and restart npp.</p>
<p dir="auto">Depending on your installation, the script directory is different,<br />
by using the way I mentioned you make sure that the correct directory is used.</p>
</blockquote>
<p dir="auto">When I go on New Script it puts me on Documents. Should I create the file there or in a place I want? I had created a folder there and put the new file named <em><a href="http://startup.py" rel="nofollow ugc">startup.py</a></em> with the script inside it, but wasn’t working, so I replaced the standard <em><a href="http://startup.py" rel="nofollow ugc">startup.py</a></em> with the new one. Didn’t work.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/25695</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/25695</guid><dc:creator><![CDATA[Alguem Meugla]]></dc:creator><pubDate>Tue, 18 Jul 2017 20:10:22 GMT</pubDate></item><item><title><![CDATA[Reply to Is there a way&#x2F;plugin that makes notepad++ run code on a file when we open it? on Tue, 18 Jul 2017 20:06:06 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/alguem-meugla" aria-label="Profile: Alguem-Meugla">@<bdi>Alguem-Meugla</bdi></a></p>
<p dir="auto">I don’t understand what you mean by</p>
<blockquote>
<p dir="auto">I copied the script to Plugins&gt;Python Script&gt;Scripts&gt;(Ctrl+)startup and saved as administrator.</p>
</blockquote>
<p dir="auto">you should have done</p>
<p dir="auto">goto <strong>Plugins-&gt;Python Script-&gt;New Script</strong> and name it <strong><a href="http://startup.py" rel="nofollow ugc">startup.py</a></strong><br />
and press Save button.<br />
Copy the posted script into the newly created document, save it and restart npp.</p>
<p dir="auto">Depending on your installation, the script directory is different,<br />
by using the way I mentioned you make sure that the correct directory is used.</p>
<p dir="auto">Cheers<br />
Claudia</p>
]]></description><link>https://community.notepad-plus-plus.org/post/25693</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/25693</guid><dc:creator><![CDATA[Claudia Frank]]></dc:creator><pubDate>Tue, 18 Jul 2017 20:06:06 GMT</pubDate></item><item><title><![CDATA[Reply to Is there a way&#x2F;plugin that makes notepad++ run code on a file when we open it? on Tue, 18 Jul 2017 20:02:53 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/claudia-frank" aria-label="Profile: Claudia-Frank">@<bdi>Claudia-Frank</bdi></a><br />
I copied the script to Plugins&gt;Python Script&gt;Scripts&gt;(Ctrl+)startup and saved as administrator.<br />
I also did what you said on Configuration.<br />
But it is doing nothing when I start my file with “NPP_COLLAPSE_IT” on a line with a -. I then changed the script and added a line “print(‘<a href="http://startup.py" rel="nofollow ugc">startup.py</a> done!’)” on the end trying to see if Plugins&gt;Python Script&gt;Show Console showed it, but nothing appears there other than Ready (and some more things above it).</p>
]]></description><link>https://community.notepad-plus-plus.org/post/25692</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/25692</guid><dc:creator><![CDATA[Alguem Meugla]]></dc:creator><pubDate>Tue, 18 Jul 2017 20:02:53 GMT</pubDate></item></channel></rss>