scripting NotePad++ configurations?
-
Is there a way to script NotePad++ configurations? For example to add “.config” to the XML parser, add “.log” to text parser, etc?
-
I am not sure “scripting” is really the word you want.
Based on your “for example”, you seem to want to associate the “.config” extension with the XML language parser, and associate the “.log” extension with the normaltext language parser.
Settings > Style Configurator
- select XML in the left
Language:
column. - Under
User Ext.:
, addconfig
(no dot)
I don’t think you need to do anything special to associate “.log” with normal text (because any extension that matches nothing will be interpreted as plain text) – unless you have a language parser that already handles “.log”: when you open a
filename.log
, what shows up in the lower left on the status bar; if it’s “Normal text file”, then it’s already using the non-parser of normal text. If it says “User Defined File – blah”, then look underLanguage > Define Your Language...
, and select the appropriateUser Language
and check the list ofExt.:
. If NPP’s status bar on the lower left says something else, look in theStyle Configurator
for a language type that matches that name, and see if it associates itself with “.log” in either theDefault ext.:
orUser ext.:
- select XML in the left
-
I understand how to do it through the UI. I want to script that same result via a PowerShell, etc. as it needs set on many systems.
-
Ah, that makes sense.
The
Language
lexer associations are stored instylers.xml
– this is found in%AppData%\Notepad++\
for normal installations, or in the same directory asnotepad++.exe
for portable or “local config” versions.For example, I have the
User Ext.:
for XML set to include.officeUI
files:<LexerType name="xml" desc="XML" ext="officeUI"> <WordsStyle name="XMLSTART" styleID="12" fgColor="FF0000" bgColor="FFFF00" fontName="" fontStyle="0" fontSize="" /> <WordsStyle name="XMLEND" styleID="13" fgColor="FF0000" bgColor="FFFF00" fontName="" fontStyle="0" fontSize="" /> <WordsStyle name="DEFAULT" styleID="0" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="1" fontSize="" /> <WordsStyle name="COMMENT" styleID="9" fgColor="008000" bgColor="FFFFFF" fontName="" fontStyle="0" fontSize="" /> <WordsStyle name="NUMBER" styleID="5" fgColor="FF0000" bgColor="FFFFFF" fontName="" fontStyle="0" fontSize="" /> <WordsStyle name="DOUBLESTRING" styleID="6" fgColor="8000FF" bgColor="FFFFFF" fontName="" fontStyle="1" fontSize="" /> <WordsStyle name="SINGLESTRING" styleID="7" fgColor="8000FF" bgColor="FFFFFF" fontName="" fontStyle="1" fontSize="" /> <WordsStyle name="TAG" styleID="1" fgColor="0000FF" bgColor="FFFFFF" fontName="" fontStyle="0" fontSize="" /> <WordsStyle name="TAGEND" styleID="11" fgColor="0000FF" bgColor="FFFFFF" fontName="" fontStyle="0" fontSize="" /> <WordsStyle name="TAGUNKNOWN" styleID="2" fgColor="0000FF" bgColor="FFFFFF" fontName="" fontStyle="0" fontSize="" /> <WordsStyle name="ATTRIBUTE" styleID="3" fgColor="FF0000" bgColor="FFFFFF" fontName="" fontStyle="0" fontSize="" /> <WordsStyle name="ATTRIBUTEUNKNOWN" styleID="4" fgColor="FF0000" bgColor="FFFFFF" fontName="" fontStyle="0" fontSize="" /> <WordsStyle name="SGMLDEFAULT" styleID="21" fgColor="000000" bgColor="A6CAF0" fontName="" fontStyle="0" fontSize="" /> <WordsStyle name="CDATA" styleID="17" fgColor="FF8000" bgColor="FFFFFF" fontName="" fontStyle="0" fontSize="" /> <WordsStyle name="ENTITY" styleID="10" fgColor="000000" bgColor="FEFDE0" fontName="" fontStyle="2" fontSize="" /> </LexerType>
The critical point is the
ext="officeUI"
attribute in the opening<LexerType ...>
tag.
In mystylers.xml
, any language that doesn’t have user-defined extensions will show up withext=""
.You could either copy the whole
stylers.xml
from your known config, or you could set up some sort of batch/remote to manually edit theext
attribute in the appropriate<LexerType ...>
tag(s). (For example, by running sed or equivalent on the remote files.)I’m not a remote-controlling-other-computers-from-powershell person, but hopefully this will get you moving in the right direction.
-
Thanks. I will explore this option.