Can you use separate fonts for separate documents?
-
Hi, NP++ team!
Right now I have two documents that I’m working on:
One uses the default “Courier New” font,
and the other uses “Nato Sans Math” font for (as you can guess) mathematical notes which contain lots of mathematical symbols and formulas.
Since I usually have multiple documents open in various tabs in the Notepad++ window, I’m wondering, is it possible to set a default font style for each document that I’m working on, so that I don’t have to switch back and forth between each font each time I’m done with one document, and move over to another?
-
Not directly. Text styling is defined by the active lexer (programming language syntax highlighting) using values from Style Configurator or UDL definition, not on a per-file basis: it’s effectively based on file type, not specific file.
However, if your “other” file has a unique extension, or if you were otherwise willing to override the Language lexer for that file, then you could define a NatoSansMath User Defined Language (UDL): if it has a specific extension (like
.math
), then you can set the UDL’s extension tomath
, and from then on, all*.math
files will open with that UDL. If you don’t have a unique extension, then you would just manually select Language > NatoSansMath for that file… and until you close the file, Notepad++ will remember the UDL applied.Inside that UDL definition, you could use the Default style to set the font for that language type.
You could also style numbers and operators differently from other text (for example, a different color) to make the mathematical operators stick out. (Please note: User Defined Language doesn’t have a concept of unicode, unfortunately, so you cannot use it to change the color of non-ASCII operators or symbols, sorry. If that’s important, ask about the workaround)- Online Usermanual overview of UDL: https://npp-user-manual.org/docs/user-defined-language-system/
- Details of each UDL field: https://ivan-radic.github.io/udl-documentation/
-
Thank you for the reply, Peter!
Renaming the math document to a
.math
extension is actually a brilliant idea, as I can still see human-readable text even when the extension is changed.Now, what I don’t know how to do is how to define NatoSansMath UDL just for this particular file extension.
When I go to Settings > Style Configurator, I can’t see anything about defining UDL for a specific file extension.
How exactly does one do this?
-
by using the Language > User Define Language > Define Your Language interface, as documented in the UDL section of the User Manual that I already linked you to.
-