Notepad++ (Text Editor)

Spread the love

If you haven’t done so already, you may want to start by reading the Preface to the Computing Series: Software as a Force Multiplier, Sections 1-3.

1. Notepad++: a programmable, extensible, feature-rich text editor

NotePad++ (NPP) is an open-source programmer’s text editor with outstanding built-in features that can be further enhanced with powerful plugins and extensively customized with your own configurations. NPPs features include syntax highlighting for a large collection of programming languages, code folding, recordable macros, cloned views, selectable shortcuts, tabbed documents, and a host of other capabilities.
But it is the plugins and customization that NPP an invaluable power-tool, capable of far more than text editing. NPP can serve as an automation engine, a complex calculator (for example between hex, binary, and decimal), or a light-weight IDE for any toolchain you wish. It is the second application (after Total Commander) which I install on a Windows computer.

This article describes a few of the dozens of capabilities. It also shares a pre-configured Notepad++ package that I use (20.0MB compressed, 50.0MB uncompressed, download here), which contains the configurations and capabilities I use. The file is portable and self-contained: just unpack NPP to your drive (in a separate folder to your current running instance) and run notepad++.exe from there.1

Notepad++, by Don Ho, multi-view with syntax highlghting

Notepad++, by Don Ho, multi-view with syntax highlghting



2. NPP Background & History

NotePad++ is developed by the French software engineer Don Ho first released in September 2003 (2 years after Ho’s graduation with an M.Sc. in Computer Science). The goal of NPP is efficient programming and low CPU consumption (Don Ho has interestingly tied the vision for his editor to be the lowest carbon footprint professional editor out there.) What this means is performance coding is key, for which reason NPP is coded in C++ using direct Win32 API and STL calls. An interview with Don Ho is here, with a little history here. After more than 20 years of development, NPP offers a highly attractive alternative to award-winning commercial proprietary text editors, (e.g. UltraEdit). (see Table 1).

What came before?

Before the arrival of Notepad++, the best text editor at the time was UltraEdit (UE), released in 1994 by Ian D. Mead, a year after Christian Ghisler started Total Commander. Indeed, TC and UE were a pair made for each other, and UE was my text editor of choice, paired with TC as file manager, when I started out in software engineering in 2001. Over the next five years, Notepad++ caught up to UE, and by 2009, NPP was a worthy alternative, and rapidly adding features. After seeing how quickly the column editing feature I had suggested had been implemented, I switched over at NPP v5.2 and haven’t looked back since.


3. Built-in Features and Capabilities

Let’s look at a few of NPP’s capabilities.

Table 1: Notepad++ Key Capabilities

  • Multi-tab editor. NPP is fast and efficient, able to load and work with dozens of files in memory with no lag and switch cleanly between them. The multi-tab editor makes access easy, and if you have more tabs than can be shown, use the Window Manager (Window > Windows…)
  • Language Syntax recognition. NPP recognizes out-of-the-box almost any programming or computing language you are likely to use, and applies styling conventions (all configurable) for easy comprehension. Language syntax add-ons can be easily inserted if there is a future language that arises. Additionally, you can define your own syntax parsers. (See Appendix E)
  • Macro recording & Playback (CTRL+SHIFT+R/P). Repetitive tasks can be made vanishingly quick by recording one instance, and then replaying (Ctrl+Shift+P) as many times as desired.
  • Column Editing (CTRL+SHIFT+Up/Down).. Column editing is useful when, e.g. inserting the same text in multiple lines simultaneously, e.g. parentheses, spaces, or changing a URL.
  • Word Wrap toggle(CTRL+W) allows just the lines, without wrapping long lines (useful e.g. in column-editing mode)
  • Line-level Bookmarks (ALT+F2/F2) can be set at any line, making it easy to move back and forth between reference points in a file. ALT+F2 sets the bookmark, F2 jump to the next bookmark.
  • Cloning view for side-by-side window for simultaneous viewing/editing of different parts of the same document.
  • Find & Replace is better than most and allows matching formatted text (e.g. tabs \t or newlines \n) as well as Regular Expressions (see Appendix C).
  • Brace Tracing (Ctrl+SHIFT+B), Code Folding (Alt+0, Alt+SHIFT+1/2/3/…/0), and Font resizing (zoom gestures). For programmers, these little touches are evident everywhere. Font resizing is easier on the eyes and helpful during screen shares or when presenting.
  • Configurable Run options. The Run menu is extensible (F5)and can be configured, e.g. to launch a selected URL in default browser using, e.g. "c:\totalake\FirefoxPortable\FirefoxPortable.exe" "$(CURRENT_WORD)" (I set the shortcut to Ctrl+F7)

4. Extended Capabilities through Plugins and Add-ons

It is through Plugins that NPP really shines. There are some exceptionally powerful plugins available for it. Here are the 16 which I have found most useful (see Table 2).

Table 2: Sixteen powerful plug-ins for extending NPP capability

  1. NPP Calc makes NPP into a built-in line by line calculator. But not just for arithmetic, almost all mathematical functions are supported, as well as programmer functions (time/date, geodistance, and many more!). Ctrl+Shift+C toggles active calculation mode. When it’s on, the current line is calculated whenever you press enter. Otherwise highlight the selection to be calculated and press Alt+Enter. See the full list of commands here. Interestingly, while combinations are listed in full, there isn’t an easy combination/permutation counting function, or even a factorial function. For this, use Maxima: e.g. binomial(5,2)
      NPP Calc is a Swiss Army Knife plugin. It includes:

    • Hex, Decimal, Binary conversion
    • Random number generator
    • Primality tester & generator
    • ASCII code generator
    • Math Expression Evaluator
    • Color Picker
    • Scriptable interfaces, including load file, edit, save, pull from clipboard, take screenshot
    • Scriptable network interfaces including test network, send ping, message broadcast
    • Unit conversions
      Example NPP file

      Editors for special needs:

    • CudaLister is an excellent colored syntax highlighting viewer and editor for TC Lister
    • NppCalc plugin allows immediate evaluation of formulas, including hex,binary,decimal conversions, all within Notepad++ (write the expression, select, Alt+ENTER)
    • HxD is a hex editor / binary file viewer and can load files > 4GB without crashing your computer
    • JuJuEdit is a large file text editor
    • NVU is an editor for HTML
    • Programmers fonts distinguish between 0 and O, and 1,l,I, amongst others. Aesthic programmer fonts are Dina and Consolas (used in CudaLister).
  2. Automation with Macros, NPP Exec, NPP Python Script, Pork2Sausage and NPPEventExec
    • Macros record keypresses and built-in NPP commands (next bookmark, next search string, etc.).
    • NPP Exec (manual, shortcut creation) allows incorporating console applications, passing input, and pasting output. See Appendix D for examples: (1) inserting a formatted timestamp using Ruby one-liner; (2) running current C file in TCC, etc.
    • NPP Python Script can automate a Plugin command (which neither macro record nor NPP Exec can call). This gives even more automated formatting possibilities. For example, we can now do a complex timestamp using NPP Calc’s facilities (see above). The downside is NPP Python Script is a bulky add-on because it requires Python itself, and if you update Python, you can break the script). The upside is NPP Python Script is able to access every single command and menu function in NPP. Using this, one can build a three line script that combines two macros and sandwiches a call to the Plugin:

      notepad.runMenuCommand('Macro', 'nppcalc-timestamp') # writes formatted text for NPP Calc, and highlights it
      notepad.runPluginCommand('NPPCalc', 'Eval Selected') # calls NPP Calc on the highlighted selection
      notepad.runMenuCommand('Macro', 'nppcalc-timestamp-cleanup') # Replaces the format text with the output

      The file itself can be saved as timestampy.py and placed in the .\Notepad++\plugins\PythonScript\scripts\timestampy.py

      Assigning custom shortcut to this (Ctrl+F5), gives, with one press the timestamp:
      2019-07-14---Sun---13:08

  3. TextFX provides text transformation tools, such as sorting, and more.
  4. TaskList scrapes a text file for TODO: and pins everything after this in a ToDo list docked to the side of NPP.
  5. NPP Snippets provides a docked panel which holds commonly used snippets, useful for TeX and other complex boilerplate insertions.
  6. One of my favorites is NPPtoR, from which NPP becomes the editor for R itself. Write some R code, press F8, and it is sent to RGui and evaluated in R.
  7. NPP Quick Color Picker runs color chooser GUIs within NPP itself, and inserts the color code selected.
  8. Dina – The Programmer’s Font – Dina font allows distinguishing similar symbols, essential for programmers to eliminate ambiguity (reduce avoidable bugs!)

    Dina – Programmer’s font helps resolve many symbol ambiguities that might otherwise lead to bugs.
    Available from https://www.dcmembers.com/jibsen/download/61/

    Configuring Notepad++ with Dina Programming font.
    Install Dina (4 fonts) into Font Control panel. This is enough for NPP. (Note – for Word, you need the Dina TTF (true type fonts))
    In NPP: Settings > Style Configurator > Global Font > Select Dina, Select size = 8 pt. Check Enable global font, size, and the 4 style types

More could be written for each of these, and the rest I have not covered. Hopefully, the above is sufficient to illustrate NPP’s potential and entice you to start experimenting. Google is your friend here. There are good discussions on each topic and plugin available on the web.

A few WARNINGS worth sharing:

  1. Notepad++ does NOT update any of its configuration files UNLESS you close it an re-open.
    * So — The danger is that if your computer crashes, all configuration changes that haven’t been followed by an orderly program close will be LOST.

  2. If you make changes to the configuration from the FILE — be careful, because closing Notepad++ will clobber those changes as Notepad++ saves down its current UI based configuration… So either save as… (i.e. temporarily rename, close, then overwrite), OR make changes through the Modify… UI dialogs.

Happy exploring!


6. Next Steps

Download the NPP extensions package I’ve provided, and play around. You can’t damage anything, so feel free to experiment!

Notepad++ : A Programmer’s Professional Text Editor


Appendix A. Quicklinks & References

  1. NotePad++ Homepage. 32-bit minimalist package (no themes, no plugins, no update, just unzip and use) (1.43MB compressed download, 4.64MB uncompressed).
  2. Notepad++ Additional Secrets
  3. Lifehacker: Getting the most out of Notepad++
  4. A comparison of competing text editors, including UltraEdit (launched 1994), Emacs, Vim, and Vi, and Microsoft Notepad
  5. Notepad++ community
  6. Plugins recently went through a disruptive change (in v7.6) Here’s the manual workaround the plugins break)
  7. Language syntax understanding comes from Ctags

Appendix B. How do I … ?

  1. …find the matching brace? Ctrl+B. Built-in capability. Default shortcut.
  2. …find the matching HTML tag?HTML Tag plugin, Ctrl+T. Included in my package.
  3. …toggle word wrap on/off to see one line per row?Ctrl+W. Built-in capability. Default shortcut.
  4. …turn on column edit mode?Alt+Shift+DnArrow. Built-in capability. Default shortcut. Keep pressing till you have all the lines you want to include. Then type or delete or amend and all lines are impacted synchronously.
  5. …reverse lines?TextFx plugin. Select section to reverse. TextFX Tools > Insert Line Numbers. TextFX Tools > Uncheck Sort ascending. TextFx Tools > Sort lines at column. TextFx Tools > Delete Line Numbers.
  6. update modified files silently?

Appendix C. Quick-start to using Regular Expressions.

Regular expressions can be used for search and replace. Below is a quickstart guide. If you understand the 12 principles below, you’ll know enough to cover 90% of the situations. For the rest, the Complete References below provide the detail.

  1. RegEx are greedy, i.e. they will match as much as possible that fits the criteria, unless ? follows, which makes the match lazy (match least possible). Examples (using Ruby):

    def parse_filename1 fn
    fn.match(/(^[^.]*)(.*)$/)
    return [$1,$2]
    end

    def parse_filename2 fn # CORRECT!
    fn.match(/(^.*)(\..*)$/)
    return [$1,$2]
    end

    def parse_filename3 fn
    fn.match(/(^.*?)(\..*)$/)
    return [$1,$2]
    end

    Which is the right one? Try it on the following filenames: “hello” “hello.txt” “hello.world.txt”
    Parser 1 explicitly specifies to stop at the first . so will return nil, “.txt” and “.world.txt” respectively.
    Parser 2 uses the greedy matching behaviour of Regexes to return nil. “.txt” and “.txt” (correct!)
    Parser 3 uses the ? modifier to request lazy matching (stops at first . so returns the same as Parser 1

  2. All matching is AND, unless pipe | is used to indicate ‘or’ matching. Example: abc|def matches abc or def.
  3. Special characters are: .[{}()\*+?|^$ These have special meanings (see below), so need to be ‘escaped \’ to reference them directly
  4. Line boundaries are caret ^ (start of line) and dollar $ (end of line)
  5. Word boundaries: \< and \> start and end of word
  6. Dot . signifies any symbol
  7. Star * means any number of matches (0 or more). Example: .* will match everything
  8. Plus + means 1 or more matches. Example el+o will match relocate, relocation, hello, yellow, jello
  9. Character sets: \d any digit, \w any alphanumeric character and underscore, \s whitespace including tab and newline
  10. Brackets [ ] allow creating customized character sets for matching. Within brackets ^ means “not”. Example: [a^bc^de] matches a single character ace but not bd
  11. Braces { } specify bounded repeats, e.g. a{3} a{3,} a{3,5} which match a three times, three or more times, and three to five times, respectively
  12. Parentheses ( ) create a named group that can later be referenced/used in replacement using \1 \2 etc. for the first, second such group.

Complete References: Find reference, Replace reference, NPP list of links

Explanations for Beginners: Micro-Guide.


Appendix D. NPP Exec Examples

NPP Exec is a powerful plugin that brings a highly configurable and user friendly shell/console into Npp.

To get the most use out of Npp Exec you will need to use the Notepad++ Environment Variables

Application 1: Printing formatted timestamp. (custom assigned shortcut Ctrl+F5)
npp_console disable // turn off output display
c:\totalcmd\Ruby\ruby.exe -e "require 'Date'; dt=DateTime.now; dname = Date::ABBR_DAYNAMES[dt.wday]; puts dt.strftime(\"%Y-%m-%d--#{dname}--%H:%M\");"
sel_settext $(OUTPUT)
npp_console enable // turn output display back on
npp_console 0 // hide console window

Application 2: Running current C file using TCC in a separate cmd window. (custom assigned shortcut Ctrl+F6)
SET TCCDIR = c:\totalcmd\tcc
npp_run $(TCCDIR)\tcc\tcc.exe -run -I$(TCCDIR)\include -I$(TCCDIR)\include\winapi -L$(TCCDIR)\lib $(FULL_CURRENT_PATH)
npp_console 0


Appendix E. NPP Syntax Highlighting

NPP supports automatic syntax highlighting for many languages out of the box. If you do not find yours, or want a different highlighting style, you can roll your own.

Language definition files are langs.xml (custom for your NPP installation), langs.model.xml (the master template provided with all NPPs). If you upgrade your NPP, new languages may appear in model but will not appear in langs.xml until/unless you copy paste them over (between <Language> and </Language> tags). This now enables the item in the Preferences > Language menu. (Remember to restart NPP)

Same thing with stylers.xml (custom for your NPP) and stylers.model.xml (master template). You will need to copy-paste over they keywords (between <LexerType> and </LexerType> tags). This now enables the language in the Settings > Edit Styler Configurators… menu. (Remember to restart NPP)

You can then associate custom file extensions to be autorecognized by the syntax highlighting engine:
Settings > Edit Styler Configurators… > find language, e.g. Forth > add User extensions (eg .fs, .4th, .f)

Example: Forth is recognized (.forth) in from 2017 onwards (v7.7.1, 2019 has it in the language menu).

You can also define your own language syntax highlighter.


Appendix F.NPP Internal Command IDs and Scintilla Message IDs

Added Feb 2024
NPPs shortcuts.xml file stores macros that you create in a concise format. However, if you want to modify the macro, it is quite a job to reverse engineer what each line is doing. To do so, you need some reference tables, which I have gathered in this appendix.
If you find this is close to what you need, but you’re missing some details, ask in the comments, and I will elaborate this section.

Table 1: Example Macro in shortcuts.xml

Example macro used as part of an auto-numbering feature in building a text-based choose-your-own-adventure (built the IDE and engine in Notepad++ for my daughter’s creative writing interest)

Table 2: Understanding a row of the recorded macro

There are 4 action types in a row of the recorded macro, each with various parameters.

Reference 3: Searchable list of Scintilla messages

Reference 4: Searchable list of Notepad++ Menu Command IDs
For reference, Notepad++ Command IDs are referenced off the following base numbers:
WM_USER=1024
NPPMSG=2024
IDM 40000
File Menu commands are IDM+1000
Edit Menu commands are IDM+2000
Search Menu commands are IDM+3000
View Menu commands are IDM+4000
Format Menu commands are IDM+5000
Language Menu commands are IDM+6000
About Menu commands are IDM+7000
Settings Menu commands are IDM+8000
Execute Menu commands are IDM+9000
System Tray Notifications are IDM+3100

The full list of individual commands is here, courtesy of the NppExec plugin.

The messages file is here.


Stay tuned for further articles in this series describing software tools I use to speed things up and build working prototypes fast.

Articles in this series:

  1. Efficient Computing: using Software as a “Force-Multiplier”
  2. Total Commander (TC): a powerful two-panel file manager (“why explore when you can command?”)
  3. Notepad++ (NPP): a programmer’s text editor.
  4. Everything: an ultra-fast desktop search engine.

Richard Hamming (Applied Mathematician)

“Knowledge and productivity are like compound interest. The more you know, the more you learn; the more you learn, the more you can do; the more you can do, the more the opportunity — it is very much like compound interest.” – Richard Hamming, You and Your Research


  1. You don’t want to overwrite your current instance, as capabilities are dependent on version of the plugin, and yours may be different than mine.

3 comments to Notepad++ (Text Editor)

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

  

  

  

Your comments are valued! (Please indulge the gatekeeping question as spam-bots cannot (yet) do simple arithmetic...) - required

Optionally add an image (JPEG only)

 

Stats: 1,089,379 article views since 2010 (Aug '24 update)

Dear Readers:

Welcome to the conversation!  We publish long-form pieces as well as a curated collection of spotlighted articles covering a broader range of topics.   Notifications for new long-form articles are through the feeds (you can join below).  We love hearing from you.  Feel free to leave your thoughts in comments, or use the contact information to reach us!

Reading List…

Looking for the best long-form articles on this site? Below is a curated list by the main topics covered.

Mathematics History & Philosophy

  1. What is Mathematics?
  2. Prehistoric Origins of Mathematics
  3. The Mathematics of Uruk & Susa (3500-3000 BCE)
  4. How Algebra Became Abstract: George Peacock & the Birth of Modern Algebra (England, 1830)
  5. The Rise of Mathematical Logic: from Laws of Thoughts to Foundations for Mathematics
  6. Mathematical Finance and The Rise of the Modern Financial Marketplace
  7. A Course in the Philosophy and Foundations of Mathematics
  8. The Development of Mathematics
  9. Catalysts in the Development of Mathematics
  10. Characteristics of Modern Mathematics

Topics in Mathematics: Pure & Applied Mathematics

  1. Fuzzy Classifiers & Quantile Statistics Techniques in Continuous Data Monitoring
  2. LOGIC in a Nutshell: Theory & Applications (including a FORTH simulator and digital circuit design)
  3. Finite Summation of Integer Powers: (Part 1 | Part 2 | Part 3)
  4. The Mathematics of Duelling
  5. A Radar Tracking Approach to Data Mining
  6. Analysis of Visitor Statistics: Data Mining in-the-Small
  7. Why Zero Raised to the Zero Power IS One

Technology: Electronics & Embedded Computing

  1. Electronics in the Junior School - Gateway to Technology
  2. Coding for Pre-Schoolers - A Turtle Logo in Forth
  3. Experimenting with Microcontrollers - an Arduino development kit for under £12
  4. Making Sensors Talk for under £5, and Voice Controlled Hardware
  5. Computer Programming: A brief survey from the 1940s to the present
  6. Forth, Lisp, & Ruby: languages that make it easy to write your own domain specific language (DSL)
  7. Programming Microcontrollers: Low Power, Small Footprints & Fast Prototypes
  8. Building a 13-key pure analog electronic piano.
  9. TinyPhoto: Embedded Graphics and Low-Fat Computing
  10. Computing / Software Toolkits
  11. Assembly Language programming (Part 1 | Part 2 | Part 3)
  12. Bare Bones Programming: The C Language

Technology: Sensors & Intelligent Systems

  1. Knowledge Engineering & the Emerging Technologies of the Next Decade
  2. Sensors and Systems
  3. Unmanned Autonomous Systems & Networks of Sensors
  4. The Advance of Marine Micro-ROVs

Maths Education

  1. Maxima: A Computer Algebra System for Advanced Mathematics & Physics
  2. Teaching Enriched Mathematics, Part 1
  3. Teaching Enriched Mathematics, Part 2: Levelling Student Success Factors
  4. A Course in the Philosophy and Foundations of Mathematics
  5. Logic, Proof, and Professional Communication: five reflections
  6. Good mathematical technique and the case for mathematical insight

Explore…

Timeline