<?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[Using a user-defined language as default?]]></title><description><![CDATA[<p dir="auto">I’ve been googling this for the last ~20 minutes and it looks like no one’s found a definitive answer yet. I downloaded a Game Maker language for Notepad ++ and would like to set it as the default language for new documents, but unfortunately no user-defined languages appear in the Settings &gt; Preferences &gt; New Document &gt; Default Language dropdown menu. Anyone know how to make this work? Thanks. =)</p>
]]></description><link>https://community.notepad-plus-plus.org/topic/11341/using-a-user-defined-language-as-default</link><generator>RSS for Node</generator><lastBuildDate>Fri, 17 Jul 2026 05:49:04 GMT</lastBuildDate><atom:link href="https://community.notepad-plus-plus.org/topic/11341.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 22 Feb 2016 00:56:53 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Using a user-defined language as default? on Wed, 09 Nov 2016 23:53:01 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/jim-dailey" aria-label="Profile: Jim-Dailey">@<bdi>Jim-Dailey</bdi></a><br />
sorry for late answer - well it depends, first version of the script<br />
looks for new files as user was asking for any new file feature.<br />
The modified version for Rich Goldman uses fnmatch as he was asking<br />
for a way to look pattern specific.</p>
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/rich-goldman" aria-label="Profile: Rich-Goldman">@<bdi>Rich-Goldman</bdi></a><br />
beside the solution Scott mentioned you might think of<br />
checking only the current file if it matches your pattern and run<br />
the MenuCommand to enable your UDL. All other files get set<br />
once switched to them - as you already stated.</p>
<p dir="auto">So something like</p>
<pre><code>if fnmatch(notepad.getCurrentFilename(), 'YOUR_PATTERN'):
     ... do your stuff ...
</code></pre>
<p dir="auto">before or after your callback definition.</p>
<p dir="auto">Cheers<br />
Claudia</p>
]]></description><link>https://community.notepad-plus-plus.org/post/19130</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/19130</guid><dc:creator><![CDATA[Claudia Frank]]></dc:creator><pubDate>Wed, 09 Nov 2016 23:53:01 GMT</pubDate></item><item><title><![CDATA[Reply to Using a user-defined language as default? on Wed, 02 Nov 2016 14:34:06 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/rich-goldman" aria-label="Profile: Rich-Goldman">@<bdi>Rich-Goldman</bdi></a></p>
<p dir="auto">If I understand the function <a class="plugin-mentions-user plugin-mentions-a" href="/user/claudia-frank" aria-label="Profile: Claudia-Frank">@<bdi>Claudia-Frank</bdi></a> wrote, even if you can somehow get the BUFFERACTIVATED notification from a command line invocation, you would still have to have ‘new’ as part of the file’s name.</p>
<p dir="auto">If that is correct and problematic, maybe you could use a simpler Python function that simply sets the language of the current file and is triggered by some hotkey? It wouldn’t be automatic, but it doesn’t seem too painful (to me).</p>
<p dir="auto">BTW, you can’t possibly be the Rich Goldman I worked with at TI in the late 80s, right? If so, you must be using an old, old picture for your avatar, or you’ve found the fountain of youth! :)</p>
]]></description><link>https://community.notepad-plus-plus.org/post/18997</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/18997</guid><dc:creator><![CDATA[Jim Dailey]]></dc:creator><pubDate>Wed, 02 Nov 2016 14:34:06 GMT</pubDate></item><item><title><![CDATA[Reply to Using a user-defined language as default? on Wed, 02 Nov 2016 13:35:05 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/rich-goldman" aria-label="Profile: Rich-Goldman">@<bdi>Rich-Goldman</bdi></a></p>
<p dir="auto">I’m not very familiar with the UDL task you’re trying to accomplish; however, it seems like after your “BUFFERACTIVATED” stuff gets set up in your <a href="http://startup.py" rel="nofollow ugc">startup.py</a>, you could trigger it with some code like this, which activates all the files currently in the editor tabs one by one:</p>
<pre><code>files_tups_list = notepad.getFiles()
curr_file = notepad.getCurrentFilename()
for tup in files_tups_list:
    file = tup[0]
    if file != curr_file:
        notepad.activateFile(file)
notepad.activateFile(curr_file)
</code></pre>
]]></description><link>https://community.notepad-plus-plus.org/post/18992</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/18992</guid><dc:creator><![CDATA[Scott Sumner]]></dc:creator><pubDate>Wed, 02 Nov 2016 13:35:05 GMT</pubDate></item><item><title><![CDATA[Reply to Using a user-defined language as default? on Wed, 02 Nov 2016 12:58:47 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/scott-sumner" aria-label="Profile: Scott-Sumner">@<bdi>Scott-Sumner</bdi></a>  Thanks - that’s exactly what I was wondering.  Sounds like I’m on the right track.  The question then becomes, can I somehow trigger the BUFFERACTIVATED signal with a python script so that the auto-UDL piece above will trigger correctly?</p>
]]></description><link>https://community.notepad-plus-plus.org/post/18989</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/18989</guid><dc:creator><![CDATA[Rich Goldman]]></dc:creator><pubDate>Wed, 02 Nov 2016 12:58:47 GMT</pubDate></item><item><title><![CDATA[Reply to Using a user-defined language as default? on Tue, 01 Nov 2016 17:16:55 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/rich-goldman" aria-label="Profile: Rich-Goldman">@<bdi>Rich-Goldman</bdi></a></p>
<p dir="auto">When Notepad++ starts up, it has to load up and activate the plugins (e.g. Pythonscript) as well as load the files you specify on the command-line.  I’m no expert on it, but I strongly suspect that your command line file(s) get loaded a lot earlier than when all the Pythonscript stuff is in place.  Thus, it can’t catch that something special should happen.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/18964</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/18964</guid><dc:creator><![CDATA[Scott Sumner]]></dc:creator><pubDate>Tue, 01 Nov 2016 17:16:55 GMT</pubDate></item><item><title><![CDATA[Reply to Using a user-defined language as default? on Tue, 01 Nov 2016 16:43:30 GMT]]></title><description><![CDATA[<p dir="auto">Hi There,<br />
I finally got around to implementing the python script solution.  The good news is - it works!   The bad news is - it doesn’t seem to work if I open a file from the command line.  For example:  I have a cygwin script that launches notepad++ and passes a file or list of files on the command line, it basically looks like:</p>
<p dir="auto">C:/Program Files (x86)/notepad++/notepad++.exe  D:/Users/bank/file.map</p>
<p dir="auto">When NPP opens - the file is shown with plain text formatting.  If I open a new file that matches my pattern, it works properly, and when I switch back to the first file it gets formatted at that moment.  But it seems the initial launch of a file from the command line isn’t sending the BUFFERACTIVATED notification, or the user-defined <a href="http://startup.py" rel="nofollow ugc">startup.py</a> runs after the very first BUFFERACTIVATED notification is pushed out.</p>
<p dir="auto">I found this on 6.9 and upgraded to 7.1 and I see the same behavior there as well.</p>
<p dir="auto">How should I work around this?  Is it a bug, or something I’m doing out of sequence?</p>
<p dir="auto">Thanks,<br />
Rich</p>
]]></description><link>https://community.notepad-plus-plus.org/post/18963</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/18963</guid><dc:creator><![CDATA[Rich Goldman]]></dc:creator><pubDate>Tue, 01 Nov 2016 16:43:30 GMT</pubDate></item><item><title><![CDATA[Reply to Using a user-defined language as default? on Fri, 15 Apr 2016 21:19:08 GMT]]></title><description><![CDATA[<p dir="auto">Hello Adam,</p>
<p dir="auto">first you need to have python script plugin installed.<br />
In case that you haven’t installed python script plugin yet, I would propose to use 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 instead of using the plugin manager.</p>
<p dir="auto">Once installed, goto<br />
Plugins-&gt;Python script-&gt;Configration<br />
and change Initialisation from LAZY to ATSTARTUP<br />
Close.</p>
<p dir="auto">Plugins-&gt;Python script-&gt;New Script</p>
<p dir="auto">copy and paste the code</p>
<pre><code>def callback_BUFFERACTIVATED(args):
    if 'new' in notepad.getBufferFilename(args['bufferID']):
        notepad.runMenuCommand('Language','HERE_THE_NAME_OF_THE_UDL')

notepad.clearCallbacks([NOTIFICATION.BUFFERACTIVATED ])
notepad.callback(callback_BUFFERACTIVATED, [NOTIFICATION.BUFFERACTIVATED ])
</code></pre>
<p dir="auto">save it as <a href="http://startup.py" rel="nofollow ugc">startup.py</a></p>
<p dir="auto">Within script replace HERE_THE_NAME_OF_THE_UDL with the name of your UDL.</p>
<p dir="auto">Save and restart npp.</p>
<p dir="auto">What does the code?<br />
Everytime a new tab gets opened the function callback_BUFFERACTIVATED gets called.<br />
It first checks if the tab has a <em><strong>new</strong></em> in its name, if so it selects the proper lexer.</p>
<p dir="auto">That’s it - I hope so.</p>
<p dir="auto">Cheers<br />
Claudia</p>
]]></description><link>https://community.notepad-plus-plus.org/post/15407</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/15407</guid><dc:creator><![CDATA[Claudia Frank]]></dc:creator><pubDate>Fri, 15 Apr 2016 21:19:08 GMT</pubDate></item><item><title><![CDATA[Reply to Using a user-defined language as default? on Fri, 15 Apr 2016 19:42:01 GMT]]></title><description><![CDATA[<p dir="auto">Thanks Claudia Seems great. However… for an idiot like me, how and where do i put this code in order to make it work.<br />
I really want to make this function happend but i need an idiotproof tutorial how to set it up :))</p>
<p dir="auto">Idiot questions:<br />
Where do i copy paste this code to?<br />
How do i make this code run as autostart?</p>
<p dir="auto">Ofcourse? i need to modify the directory to?<br />
“language” and ttp should be changed to?</p>
<p dir="auto">XD</p>
<p dir="auto">Thats my level. Thanks would be great to get this done.<br />
For myself and for my friend at work who prepares fixtures for a huge ass fiber cutter that cut through 8mm steel np and he also asked me if i could help him with loading his language as autostart default.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/15401</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/15401</guid><dc:creator><![CDATA[Adam Kley]]></dc:creator><pubDate>Fri, 15 Apr 2016 19:42:01 GMT</pubDate></item><item><title><![CDATA[Reply to Using a user-defined language as default? on Tue, 23 Feb 2016 18:03:43 GMT]]></title><description><![CDATA[<p dir="auto">Hello <a class="plugin-mentions-user plugin-mentions-a" href="/user/rich-goldman" aria-label="Profile: Rich-Goldman">@<bdi>Rich-Goldman</bdi></a>,</p>
<p dir="auto">in general, yes but of course not with the provided example.<br />
I would use fnmatch to make the pattern comparison, so something like</p>
<pre><code>from fnmatch import fnmatch

def callback_BUFFERACTIVATED(args):
    _file = notepad.getBufferFilename(args['bufferID'])
    if fnmatch(_file, '*\Notepad++\plugins\Con*\Python*\*\*.py'):
        current_bufferID = str(args['bufferID'])
        if editor.getProperty(current_bufferID) != '1':
            editor.setProperty(current_bufferID, '1')
            notepad.runMenuCommand('Language','ttp')

notepad.clearCallbacks([NOTIFICATION.BUFFERACTIVATED ])
notepad.callback(callback_BUFFERACTIVATED, [NOTIFICATION.BUFFERACTIVATED ])
</code></pre>
<p dir="auto">Example makes no sense but is provided to see that it can be done.<br />
fnmatch works as dir within cmd shell.<br />
get and setProperty are used to set lexer only once.<br />
Of course you need to modify</p>
<pre><code>if fnmatch(_file, '*\Notepad++\plugins\Con*\Python*\*\*.py'):
</code></pre>
<p dir="auto">and</p>
<pre><code>notepad.runMenuCommand('Language','ttp')
</code></pre>
<p dir="auto">In addition you can also use regex to match certain files.</p>
<p dir="auto">Cheers<br />
Claudia</p>
]]></description><link>https://community.notepad-plus-plus.org/post/14238</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/14238</guid><dc:creator><![CDATA[Claudia Frank]]></dc:creator><pubDate>Tue, 23 Feb 2016 18:03:43 GMT</pubDate></item><item><title><![CDATA[Reply to Using a user-defined language as default? on Tue, 23 Feb 2016 14:35:18 GMT]]></title><description><![CDATA[<p dir="auto">Hi there,</p>
<p dir="auto">This is a feature I’ve been hoping for for a very long time.  The python script looks like an ideal workaround.  I’m a bit unskilled with Python, but, would this work if I knew a specific pattern for the file I was opening?  For example if I knew the path to the file had the string ‘/bank/*/src/[0-9]*’  (almost a regex but not quite).</p>
<p dir="auto">Thanks in advance!<br />
Rich G.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/14229</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/14229</guid><dc:creator><![CDATA[Rich Goldman]]></dc:creator><pubDate>Tue, 23 Feb 2016 14:35:18 GMT</pubDate></item><item><title><![CDATA[Reply to Using a user-defined language as default? on Tue, 23 Feb 2016 00:39:17 GMT]]></title><description><![CDATA[<p dir="auto">Hello <a class="plugin-mentions-user plugin-mentions-a" href="/user/travis-farris" aria-label="Profile: Travis-Farris">@<bdi>Travis-Farris</bdi></a>,</p>
<p dir="auto">as you already said, this cannot be achieved by npp natively.<br />
My solution to the porblem would involve the python script plugin<br />
and this little script.</p>
<pre><code>def callback_BUFFERACTIVATED(args):
    if 'new' in notepad.getBufferFilename(args['bufferID']):
        notepad.runMenuCommand('Language','HERE_THE_NAME_OF_THE_UDL')

notepad.clearCallbacks([NOTIFICATION.BUFFERACTIVATED ])
notepad.callback(callback_BUFFERACTIVATED, [NOTIFICATION.BUFFERACTIVATED ])
</code></pre>
<p dir="auto">Current version has some disadvantages like, every time you activate a new… document it calls<br />
the runMenuCommand to set the udl, even if it was already set and if you chose a different lexer but keep<br />
the name of the document new… it will reset it once you reactivate it.</p>
<p dir="auto">So it’s up to you to</p>
<p dir="auto">a) decide if you wanna go this way and if so<br />
b) how you would handle the mentioned disadvantages. E.g. we could modify it like<br />
providing some property which indicates that this file has been already set or something else.</p>
<p dir="auto">Cheers<br />
Claudia</p>
]]></description><link>https://community.notepad-plus-plus.org/post/14224</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/14224</guid><dc:creator><![CDATA[Claudia Frank]]></dc:creator><pubDate>Tue, 23 Feb 2016 00:39:17 GMT</pubDate></item></channel></rss>