{"id":3268,"date":"2019-07-14T13:15:57","date_gmt":"2019-07-14T12:15:57","guid":{"rendered":"http:\/\/mathscitech.org\/articles\/?p=3268"},"modified":"2024-05-12T13:41:54","modified_gmt":"2024-05-12T12:41:54","slug":"npp","status":"publish","type":"post","link":"https:\/\/mathscitech.org\/articles\/npp","title":{"rendered":"Notepad++ (Text Editor)"},"content":{"rendered":"<p><em>If you haven&#8217;t done so already, you may want to start by reading the Preface to the Computing Series: <a href=\"https:\/\/mathscitech.org\/articles\/computing-toolkits\" rel=\"noopener\" target=\"_blank\">Software as a Force Multiplier<\/a>, Sections 1-3.<\/em><\/p>\n<p><!--\n\n<h1>Notepad++: a programmer's text editor<\/h1>\n\n--><\/p>\n<h4>1. Notepad++: a programmable, extensible, feature-rich text editor<\/h4>\n<p><a href=\"https:\/\/notepad-plus-plus.org\/\" target=\"_blank\" rel=\"noopener noreferrer\">NotePad++<\/a> (NPP) is an open-source programmer&#8217;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.<br \/>\n 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 <a href=\"https:\/\/mathscitech.org\/articles\/totcmd\" target=\"_blank\" rel=\"noopener noreferrer\">Total Commander<\/a>) which I install on a Windows computer.<\/p>\n<p>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, <a href=\"#download\">download here<\/a>), 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.<sup class='footnote'><a href='#fn-3268-1' id='fnref-3268-1' onclick='return fdfootnote_show(3268)'>1<\/a><\/sup><\/p>\n<p><div id=\"attachment_3318\" style=\"width: 1376px\" class=\"wp-caption aligncenter\"><img decoding=\"async\" aria-describedby=\"caption-attachment-3318\" loading=\"lazy\" src=\"https:\/\/mathscitech.org\/articles\/wp-content\/uploads\/2019\/07\/01-my_notepad-.png\" alt=\"Notepad++, by Don Ho, multi-view with syntax highlghting\" width=\"1366\" height=\"739\" class=\"size-full wp-image-3318\" srcset=\"https:\/\/mathscitech.org\/articles\/wp-content\/uploads\/2019\/07\/01-my_notepad-.png 1366w, https:\/\/mathscitech.org\/articles\/wp-content\/uploads\/2019\/07\/01-my_notepad--300x162.png 300w, https:\/\/mathscitech.org\/articles\/wp-content\/uploads\/2019\/07\/01-my_notepad--800x433.png 800w, https:\/\/mathscitech.org\/articles\/wp-content\/uploads\/2019\/07\/01-my_notepad--150x81.png 150w, https:\/\/mathscitech.org\/articles\/wp-content\/uploads\/2019\/07\/01-my_notepad--400x216.png 400w\" sizes=\"auto, (max-width: 1366px) 100vw, 1366px\" \/><p id=\"caption-attachment-3318\" class=\"wp-caption-text\">Notepad++, by Don Ho, multi-view with syntax highlghting<\/p><\/div><br \/>\n<!--more--><\/p>\n<hr>\n<h4>2. NPP Background &#038; History<\/h4>\n<p><a href=\"https:\/\/notepad-plus-plus.org\/\" target=\"_blank\" rel=\"noopener noreferrer\">NotePad++<\/a> is developed by the French software engineer <a href=\"https:\/\/donho.github.io\/\" rel=\"noopener noreferrer\" target=\"_blank\">Don Ho<\/a> first released in September 2003 (2 years after Ho&#8217;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 <a href=\"https:\/\/theinitialcommit.com\/2017\/05\/30\/don-ho\/\" rel=\"noopener noreferrer\" target=\"_blank\">interview with Don Ho<\/a> is here, with a little history <a href=\"https:\/\/en.wikipedia.org\/wiki\/Notepad%2B%2B\" rel=\"noopener noreferrer\" target=\"_blank\">here<\/a>.  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).<\/p>\n<h4>What came before?<\/h4>\n<p>Before the arrival of Notepad++, the best text editor at the time was <a href=\"https:\/\/www.ultraedit.com\/\" rel=\"noopener noreferrer\" target=\"_blank\">UltraEdit<\/a> (UE), released in 1994 by Ian D. Mead, a year after Christian Ghisler started <a href=\"https:\/\/mathscitech.org\/articles\/totcmd\" rel=\"noopener noreferrer\" target=\"_blank\">Total Commander<\/a>.  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 <a href=\"https:\/\/notepad-plus-plus.org\/download\/all-versions.html\" rel=\"noopener noreferrer\" target=\"_blank\">rapidly adding features<\/a>.  After seeing how quickly the column editing feature I had suggested had been implemented, I switched over at NPP v5.2 and haven&#8217;t looked back since.<\/p>\n<hr\/>\n<h4>3. Built-in Features and Capabilities<\/h4>\n<p>Let&#8217;s look at a few of NPP&#8217;s capabilities.<br \/>\n<div style=\"width: 441px\" class=\"wp-caption aligncenter\"><img decoding=\"async\" loading=\"lazy\" class=\"\" src=\"https:\/\/www.mathscitech.org\/code\/npp\/npp02-capabilities.png\" alt=\"\" width=\"431\" height=\"283\" \/><p class=\"wp-caption-text\">Table 1: Notepad++ Key Capabilities<\/p><\/div><\/p>\n<ul>\n<li><strong>Multi-tab editor.<\/strong>  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 &gt; Windows&#8230;)\n<li><strong>Language Syntax recognition.<\/strong>  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 <a href=\"#appendix-syntax\" rel=\"noopener noreferrer\" target=\"_blank\">Appendix E<\/a>)\n<li><strong>Macro recording &#038; Playback (CTRL+SHIFT+R\/P)<\/strong>.  Repetitive tasks can be made vanishingly quick by recording one instance, and then replaying (Ctrl+Shift+P) as many times as desired.\n<li><strong>Column Editing (CTRL+SHIFT+Up\/Down).<\/strong>.  Column editing is useful when, e.g. inserting the same text in multiple lines simultaneously, e.g. parentheses, spaces, or changing a URL.\n<li><strong>Word Wrap toggle(CTRL+W)<\/strong> allows just the lines, without wrapping long lines (useful e.g. in column-editing mode)\n<li><strong>Line-level Bookmarks (ALT+F2\/F2)<\/strong> 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.\n<li>Cloning view for side-by-side window for simultaneous viewing\/editing of different parts of the same document.\n<li><strong>Find &amp; Replace<\/strong> is better than most and allows matching formatted text (e.g. tabs \\t or newlines \\n) as well as Regular Expressions (see <a href=\"#appendix-regex\">Appendix C<\/a>).\n<li><strong>Brace Tracing (Ctrl+SHIFT+B), Code Folding (Alt+0, Alt+SHIFT+1\/2\/3\/&#8230;\/0), and Font resizing (zoom gestures).<\/strong>  For programmers, these little touches are evident everywhere.  Font resizing is easier on the eyes and helpful during screen shares or when presenting.\n<li><strong>Configurable Run options<\/strong>.  The Run menu is extensible (F5)and can be configured, e.g. to launch a selected URL in default browser using, e.g. <code>\"c:\\totalake\\FirefoxPortable\\FirefoxPortable.exe\" \"$(CURRENT_WORD)\"<\/code> (I set the shortcut to Ctrl+F7)\n<\/ul>\n<hr\/>\n<h4>4. Extended Capabilities through Plugins and Add-ons<\/h4>\n<p>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).<\/p>\n<div style=\"width: 542px\" class=\"wp-caption aligncenter\"><img decoding=\"async\" loading=\"lazy\" class=\"\" src=\"https:\/\/www.mathscitech.org\/code\/npp\/npp03-plugins.png\" alt=\"\" width=\"532\" height=\"424\" \/><p class=\"wp-caption-text\">Table 2: Sixteen powerful plug-ins for extending NPP capability<\/p><\/div>\n<ol>\n<li><strong>NPP Calc<\/strong> makes NPP into a built-in line by line calculator. But <a href=\"https:\/\/www.mathscitech.org\/code\/npp\/HelpNppCalcEn_1.5.txt\" target=\"_blank\" rel=\"noopener noreferrer\">not just for arithmetic, almost all mathematical functions are supported, as well as programmer functions (time\/date, geodistance, and many more!<\/a>). Ctrl+Shift+C toggles active calculation mode. When it&#8217;s on, the current line is calculated whenever you press enter. Otherwise highlight the selection to be calculated and press Alt+Enter. See the <a href=\"https:\/\/www.mathscitech.org\/code\/npp\/HelpNppCalcEn_1.5.txt\" target=\"_blank\" rel=\"noopener noreferrer\">full list of commands here<\/a>.  Interestingly, while combinations are listed in full, there isn&#8217;t an easy combination\/permutation counting function, or even a factorial function.  For this, <a href=\"https:\/\/mathscitech.org\/articles\/computing-toolkits\/maxima\" rel=\"noopener\" target=\"_blank\">use Maxima<\/a>: e.g. <code>binomial(5,2)<\/code>\n<ul>\nNPP Calc is a Swiss Army Knife plugin.  It includes:<\/p>\n<li>Hex, Decimal, Binary conversion\n<li>Random number generator\n<li>Primality tester &#038; generator\n<li>ASCII code generator\n<li>Math Expression Evaluator\n<li>Color Picker\n<li>Scriptable interfaces, including load file, edit, save, pull from clipboard, take screenshot\n<li>Scriptable network interfaces including test network, send ping, message broadcast\n<li>Unit conversions<br \/>\n<a href=\"https:\/\/www.mathscitech.org\/code\/totalcmd\/nppcalc.txt\" rel=\"noopener\" target=\"_blank\">Example NPP file<\/a><\/p>\n<p>Editors for special needs:<\/p>\n<li><a href=\"https:\/\/www.bytesin.com\/software\/CudaLister\/\" rel=\"noopener\" target=\"_blank\">CudaLister<\/a> is an excellent colored syntax highlighting viewer and editor for TC Lister\n<li>NppCalc plugin allows immediate evaluation of formulas, including hex,binary,decimal conversions, all within Notepad++ (write the expression, select, Alt+ENTER)\n<li>HxD is a <a href=\"https:\/\/thestarman.pcministry.com\/tool\/HexEds.htm\" rel=\"noopener\" target=\"_blank\">hex editor<\/a> \/ binary file viewer and can load files > 4GB without crashing your computer\n<li>JuJuEdit is a large file text editor\n<li>NVU is an editor for HTML\n<li>Programmers fonts distinguish between 0 and O, and 1,l,I, amongst others.  Aesthic programmer fonts are Dina and Consolas (used in CudaLister).\n<\/ul>\n<li><strong>Automation with Macros, NPP Exec, NPP Python Script, Pork2Sausage and NPPEventExec<\/strong>\n<ul>\n<li> Macros record keypresses and built-in NPP commands (next bookmark, next search string, etc.).\n<li> NPP Exec (<a href=\"https:\/\/www.cin.ufpe.br\/~aedv\/Notepad++Portable\/App\/Notepad++_ansi\/plugins\/doc\/NppExec_Manual.txt\" rel=\"noopener noreferrer\" target=\"_blank\">manual<\/a>, <a href=\"https:\/\/riptutorial.com\/notepadplusplus\/example\/12662\/nppexec\" rel=\"noopener noreferrer\" target=\"_blank\">shortcut creation<\/a>) allows incorporating console applications, passing input, and pasting output. See <a href=\"#appendix-nppexec\">Appendix D<\/a> for examples: (1) <a href=\"https:\/\/superuser.com\/questions\/463751\/using-nppexec-and-ruby-to-script-a-new-macro-feature-for-notepad\" target=\"_blank\" rel=\"noopener noreferrer\">inserting a formatted timestamp using Ruby one-liner<\/a>; (2) running current C file in TCC, etc.\n<li> 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&#8217;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:\n<p><code>notepad.runMenuCommand('Macro', 'nppcalc-timestamp') # writes formatted text for NPP Calc, and highlights it<br \/>\nnotepad.runPluginCommand('NPPCalc', 'Eval Selected') # calls NPP Calc on the highlighted selection<br \/>\nnotepad.runMenuCommand('Macro', 'nppcalc-timestamp-cleanup') # Replaces the format text with the output<br \/>\n<\/code><\/p>\n<p>The file itself can be saved as timestampy.py and placed in the <tt>.\\Notepad++\\plugins\\PythonScript\\scripts\\timestampy.py<\/tt><\/p>\n<p>Assigning custom shortcut to this (Ctrl+F5), gives, with one press the timestamp:<br \/>\n<code>2019-07-14---Sun---13:08<\/code>\n<\/ul>\n<li><strong>TextFX<\/strong> provides text transformation tools, such as sorting, and more.\n<li><strong>TaskList<\/strong> scrapes a text file for TODO: and pins everything after this in a ToDo list docked to the side of NPP.\n<li><strong>NPP Snippets<\/strong> provides a docked panel which holds commonly used snippets, useful for TeX and other complex boilerplate insertions.\n<li>One of my favorites is <strong>NPPtoR<\/strong>, from which <a href=\"https:\/\/mathscitech.org\/articles\/computing-toolkits\/r-for-stats\" rel=\"noopener noreferrer\" target=\"_blank\">NPP becomes the editor for R<\/a> itself. Write some R code, press F8, and it is sent to RGui and evaluated in R.\n<li><strong>NPP Quick Color Picker<\/strong> runs color chooser GUIs within NPP itself, and inserts the color code selected.\n<li><strong><a href=\"https:\/\/www.dcmembers.com\/jibsen\/download\/61\/\" rel=\"noopener noreferrer\" target=\"_blank\">Dina &#8211; The Programmer&#8217;s Font<\/a><\/strong> &#8211; Dina font allows distinguishing similar symbols, essential for programmers to eliminate ambiguity (reduce avoidable bugs!)<br \/>\n<div id=\"attachment_5070\" style=\"width: 891px\" class=\"wp-caption aligncenter\"><img decoding=\"async\" aria-describedby=\"caption-attachment-5070\" loading=\"lazy\" src=\"https:\/\/mathscitech.org\/articles\/wp-content\/uploads\/2019\/07\/screenshot.1603.png\" alt=\"\" width=\"881\" height=\"232\" class=\"size-full wp-image-5070\" srcset=\"https:\/\/mathscitech.org\/articles\/wp-content\/uploads\/2019\/07\/screenshot.1603.png 881w, https:\/\/mathscitech.org\/articles\/wp-content\/uploads\/2019\/07\/screenshot.1603-300x79.png 300w, https:\/\/mathscitech.org\/articles\/wp-content\/uploads\/2019\/07\/screenshot.1603-800x211.png 800w, https:\/\/mathscitech.org\/articles\/wp-content\/uploads\/2019\/07\/screenshot.1603-768x202.png 768w, https:\/\/mathscitech.org\/articles\/wp-content\/uploads\/2019\/07\/screenshot.1603-150x40.png 150w, https:\/\/mathscitech.org\/articles\/wp-content\/uploads\/2019\/07\/screenshot.1603-400x105.png 400w\" sizes=\"auto, (max-width: 881px) 100vw, 881px\" \/><p id=\"caption-attachment-5070\" class=\"wp-caption-text\">Dina &#8211; Programmer&#8217;s font helps resolve many symbol ambiguities that might otherwise lead to bugs.<br \/>Available from https:\/\/www.dcmembers.com\/jibsen\/download\/61\/<\/p><\/div><\/p>\n<p><em>Configuring Notepad++ with Dina Programming font.<\/em><br \/>\nInstall Dina (4 fonts) into Font Control panel.  This is enough for NPP.  (Note &#8211; for Word, you need the Dina TTF (true type fonts))<br \/>\nIn NPP: Settings > Style Configurator > Global Font > Select Dina, Select size = 8 pt.  Check Enable global font, size, and the 4 style types<\/p>\n<\/ol>\n<p>More could be written for each of these, and the rest I have not covered.  Hopefully, the above is sufficient to illustrate NPP&#8217;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.  <\/p>\n<p>A few WARNINGS worth sharing:<\/p>\n<ol>\n<li> Notepad++ does NOT update any of its configuration files UNLESS you close it an re-open.<br \/>\n* So &#8212; The danger is that if your computer crashes, all configuration changes that haven&#8217;t been followed by an orderly program close will be LOST.<\/p>\n<li> If you make changes to the configuration from the FILE &#8212; be careful, because closing Notepad++ will clobber those changes as Notepad++ saves down its current UI based configuration&#8230;  So either save as&#8230; (i.e. temporarily rename, close, then overwrite), OR make changes through the Modify&#8230; UI dialogs.\n<\/ol>\n<p>Happy exploring!<\/p>\n<hr\/>\n<p><a id=\"download\"><\/a><\/p>\n<h4>6. Next Steps<\/h4>\n<p><a href=\"https:\/\/www.mathscitech.org\/code\/npp\/Npp.zip\">Download the NPP extensions package<\/a> I&#8217;ve provided, and play around. You can&#8217;t damage anything, so feel free to experiment!<\/p>\n<ul>\n<li><a href=\"https:\/\/www.mathscitech.org\/code\/npp\/Npp.zip\" target=\"_blank\" rel=\"noopener noreferrer\">Notepad++ extensions package pre-configured with all plugins etc.<\/a> (20.0MB compressed, 50.0MB uncompressed)<\/li>\n<li>Unpack it to <code>c:\\totalcmd\\Npp<\/code>.  This integrates NPP as the external editor within the pre-configured <a href=\"https:\/\/mathscitech.org\/articles\/totcmd\" target=\"_blank\" rel=\"noopener noreferrer\">Total Commander<\/a> package.\n<\/ul>\n<div style=\"width: 237px\" class=\"wp-caption aligncenter\"><img decoding=\"async\" loading=\"lazy\" class=\"\" src=\"https:\/\/www.mathscitech.org\/code\/npp\/npp01-icon.png\" alt=\"\" width=\"227\" height=\"232\" \/><p class=\"wp-caption-text\">Notepad++ : A Programmer&#8217;s Professional Text Editor<\/p><\/div>\n<hr\/>\n<h4>Appendix A. Quicklinks &#038; References<\/h4>\n<ol>\n<li><a href=\"https:\/\/notepad-plus-plus.org\/\" target=\"_blank\" rel=\"noopener noreferrer\">NotePad++ Homepage<\/a>.  <a href=\"https:\/\/notepad-plus-plus.org\/download\/v7.7.1.html\" rel=\"noopener noreferrer\" target=\"_blank\">32-bit minimalist package<\/a> (no themes, no plugins, no update, just unzip and use) (1.43MB compressed download, 4.64MB uncompressed).<\/li>\n<li><a href=\"https:\/\/www.martinrinehart.com\/frontend-engineering\/engineers\/tools\/notepad-pp.html\" rel=\"noopener noreferrer\" target=\"_blank\">Notepad++ Additional Secrets<\/a>\n<li><a href=\"https:\/\/lifehacker.com\/how-to-get-more-plus-out-of-notepad-5686272\" rel=\"noopener noreferrer\" target=\"_blank\">Lifehacker: Getting the most out of Notepad++<\/a>\n<li>A <a href=\"https:\/\/en.wikipedia.org\/wiki\/Comparison_of_text_editors\" rel=\"noopener noreferrer\" target=\"_blank\">comparison of competing text editors<\/a>, including UltraEdit (launched 1994), Emacs, Vim, and Vi, and Microsoft Notepad\n<li><a href=\"https:\/\/notepad-plus-plus.org\/community\/\" rel=\"noopener noreferrer\" target=\"_blank\">Notepad++ community<\/a>\n<li>Plugins recently went through a <a href=\"https:\/\/notepad-plus-plus.org\/community\/topic\/16996\/new-plugins-home-round-2\/23\" rel=\"noopener noreferrer\" target=\"_blank\">disruptive change<\/a> (in v7.6)  Here&#8217;s the <a href=\"https:\/\/notepad-plus-plus.org\/news\/notepad-7.6.1-released.html\" rel=\"noopener noreferrer\" target=\"_blank\">manual workaround the plugins break)<\/a>\n<li>Language syntax understanding comes from <a href=\"https:\/\/en.wikipedia.org\/wiki\/Ctags\" rel=\"noopener noreferrer\" target=\"_blank\">Ctags<\/a>\n<\/ol>\n<hr\/>\n<h4>Appendix B. How do I &#8230; ?<\/h4>\n<ol>\n<li><strong>&#8230;find the matching brace?<\/strong> Ctrl+B.  Built-in capability.  Default shortcut.\n<li><strong>&#8230;find the matching HTML tag?<\/strong>HTML Tag plugin, Ctrl+T.  Included in my package.\n<li><strong>&#8230;toggle word wrap on\/off to see one line per row?<\/strong>Ctrl+W.  Built-in capability.  Default shortcut.\n<li><strong>&#8230;turn on column edit mode?<\/strong>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.\n<li><strong>&#8230;reverse lines?<\/strong>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.\n<li><strong>&#8230;<a href=\"https:\/\/superuser.com\/questions\/274961\/how-to-automatically-reload-modified-files-in-notepad\" rel=\"noopener\" target=\"_blank\">update modified files silently<\/a>?<\/strong>\n<\/ol>\n<hr\/>\n<h4><a name=\"appendix-regex\">Appendix C.<\/a> Quick-start to using Regular Expressions.<\/h4>\n<p>Regular expressions can be used for search and replace.  Below is a quickstart guide.  If you understand the 12 principles below, you&#8217;ll know enough to cover 90% of the situations.  For the rest, the Complete References below provide the detail.<\/p>\n<ol>\n<li> 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):<br \/>\n<code><br \/>\ndef parse_filename1 fn<br \/>\n    fn.match(\/(^[^.]*)(.*)$\/)<br \/>\n    return [$1,$2]<br \/>\nend<\/p>\n<p>def parse_filename2 fn  # CORRECT!<br \/>\n    fn.match(\/(^.*)(\\..*)$\/)<br \/>\n    return [$1,$2]<br \/>\nend<\/p>\n<p>def parse_filename3 fn<br \/>\n    fn.match(\/(^.*?)(\\..*)$\/)<br \/>\n    return [$1,$2]<br \/>\nend<br \/>\n<\/code><br \/>\nWhich is the right one?  Try it on the following filenames: &#8220;hello&#8221;  &#8220;hello.txt&#8221;  &#8220;hello.world.txt&#8221;<br \/>\nParser 1 explicitly specifies to stop at the first . so will return nil, &#8220;.txt&#8221; and &#8220;.world.txt&#8221; respectively.<br \/>\nParser 2 uses the greedy matching behaviour of Regexes to return nil. &#8220;.txt&#8221; and &#8220;.txt&#8221; (correct!)<br \/>\nParser 3 uses the ? modifier to request lazy matching (stops at first . so returns the same as Parser 1<\/p>\n<li> All matching is AND, unless pipe | is used to indicate &#8216;or&#8217; matching.  Example: abc|def matches abc or def.\n<li> Special characters are: .[{}()\\*+?|^$   These have special meanings (see below), so need to be &#8216;escaped \\&#8217; to reference them directly\n<li> Line boundaries are caret ^ (start of line) and dollar $ (end of line)\n<li> Word boundaries: \\< and \\> start and end of word\n<li> Dot . signifies any symbol\n<li> Star * means any number of matches (0 or more).  Example: .* will match everything\n<li> Plus + means 1 or more matches.  Example el+o will match relocate, relocation, hello, yellow, jello\n<li> Character sets: \\d any digit, \\w any alphanumeric character and underscore, \\s whitespace including tab and newline\n<li> Brackets [ ] allow creating customized character sets for matching.  Within brackets ^ means &#8220;not&#8221;.  Example: [a^bc^de] matches a single character ace but not bd\n<li> 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\n<li> Parentheses ( ) create a named group that can later be referenced\/used in replacement using \\1 \\2 etc. for the first, second such group.\n<\/ol>\n<p>Complete References: <a href=\"https:\/\/www.boost.org\/doc\/libs\/1_55_0\/libs\/regex\/doc\/html\/boost_regex\/syntax\/perl_syntax.html\" rel=\"noopener noreferrer\" target=\"_blank\">Find reference<\/a>, <a href=\"https:\/\/www.boost.org\/doc\/libs\/1_55_0\/libs\/regex\/doc\/html\/boost_regex\/format\/boost_format_syntax.html\" rel=\"noopener noreferrer\" target=\"_blank\">Replace reference<\/a>, <a href=\"https:\/\/community.notepad-plus-plus.org\/topic\/15765\/faq-desk-where-to-find-regex-documentation\" rel=\"noopener noreferrer\" target=\"_blank\">NPP list of links<\/a><\/p>\n<p>Explanations for Beginners: <a href=\"https:\/\/blog.hakzone.info\/posts-and-articles\/editors\/understanding-regex-with-notepad\/comment-page-1\/\" rel=\"noopener noreferrer\" target=\"_blank\">Micro-Guide<\/a>.<\/p>\n<hr\/>\n<h4><a name=\"appendix-nppexec\">Appendix D.<\/a> NPP Exec Examples<\/h4>\n<p>NPP Exec is a powerful plugin that brings a highly configurable and user friendly shell\/console into Npp.<\/p>\n<p>To get the most use out of Npp Exec you will need to use the <a href=\"https:\/\/web.archive.org\/web\/20130530035955\/http:\/\/npp-community.tuxfamily.org:80\/documentation\/notepad-user-manual\/commands\" rel=\"noopener\" target=\"_blank\">Notepad++ Environment Variables<\/a><\/p>\n<p>Application 1: Printing formatted timestamp.  (custom assigned shortcut Ctrl+F5)<br \/>\n<code>npp_console disable             \/\/ turn off output display<br \/>\nc:\\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\\\");\"<br \/>\nsel_settext $(OUTPUT)<br \/>\nnpp_console enable              \/\/ turn output display back on<br \/>\nnpp_console 0                   \/\/ hide console window<br \/>\n<\/code><\/p>\n<p>Application 2: Running current C file using TCC in a separate cmd window. (custom assigned shortcut Ctrl+F6)<br \/>\n<code>SET TCCDIR = c:\\totalcmd\\tcc<br \/>\nnpp_run $(TCCDIR)\\tcc\\tcc.exe -run -I$(TCCDIR)\\include -I$(TCCDIR)\\include\\winapi -L$(TCCDIR)\\lib $(FULL_CURRENT_PATH)<br \/>\nnpp_console 0<\/code><\/p>\n<hr\/>\n<h4><a name=\"appendix-syntax\">Appendix E.<\/a> NPP Syntax Highlighting<\/h4>\n<p>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.<\/p>\n<p>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 &lt;Language&gt; and &lt;\/Language&gt; tags).  This now enables the item in the Preferences > Language menu.  (Remember to restart NPP)<\/p>\n<p>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 &lt;LexerType&gt; and &lt;\/LexerType&gt; tags).  This now enables the language in the Settings > Edit Styler Configurators&#8230; menu.  (Remember to restart NPP)<\/p>\n<p>You can then associate custom file extensions to be autorecognized by the syntax highlighting engine:<br \/>\nSettings > Edit Styler Configurators&#8230; > find language, e.g. Forth > add User extensions (eg .fs, .4th, .f)<\/p>\n<p>Example: Forth is recognized (.forth) in from 2017 onwards (v7.7.1, 2019 has it in the language menu).<\/p>\n<p>You can also define your own language syntax highlighter.<\/p>\n<hr\/>\n<h4><a id=\"appendix-internals\">Appendix F.<\/a>NPP Internal Command IDs and Scintilla Message IDs<\/h4>\n<p><em>Added Feb 2024<\/em><br \/>\nNPPs 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.<br \/>\nIf you find this is close to what you need, but you&#8217;re missing some details, ask in the comments, and I will elaborate this section.<\/p>\n<p><strong>Table 1: Example Macro in shortcuts.xml<\/strong><br \/>\n<div id=\"attachment_11304\" style=\"width: 650px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/mathscitech.org\/articles\/wp-content\/uploads\/2024\/02\/screenshot.2766.png\"><img decoding=\"async\" aria-describedby=\"caption-attachment-11304\" loading=\"lazy\" src=\"https:\/\/mathscitech.org\/articles\/wp-content\/uploads\/2024\/02\/screenshot.2766-800x311.png\" alt=\"\" width=\"640\" height=\"249\" class=\"size-large wp-image-11304\" srcset=\"https:\/\/mathscitech.org\/articles\/wp-content\/uploads\/2024\/02\/screenshot.2766-800x311.png 800w, https:\/\/mathscitech.org\/articles\/wp-content\/uploads\/2024\/02\/screenshot.2766-300x117.png 300w, https:\/\/mathscitech.org\/articles\/wp-content\/uploads\/2024\/02\/screenshot.2766-768x298.png 768w, https:\/\/mathscitech.org\/articles\/wp-content\/uploads\/2024\/02\/screenshot.2766-150x58.png 150w, https:\/\/mathscitech.org\/articles\/wp-content\/uploads\/2024\/02\/screenshot.2766-400x155.png 400w, https:\/\/mathscitech.org\/articles\/wp-content\/uploads\/2024\/02\/screenshot.2766.png 870w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><\/a><p id=\"caption-attachment-11304\" class=\"wp-caption-text\">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&#8217;s creative writing interest)<\/p><\/div><\/p>\n<p><strong>Table 2: Understanding a row of the recorded macro<\/strong><br \/>\n<div id=\"attachment_11303\" style=\"width: 671px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/mathscitech.org\/articles\/wp-content\/uploads\/2024\/02\/screenshot.2765.png\"><img decoding=\"async\" aria-describedby=\"caption-attachment-11303\" loading=\"lazy\" src=\"https:\/\/mathscitech.org\/articles\/wp-content\/uploads\/2024\/02\/screenshot.2765.png\" alt=\"\" width=\"661\" height=\"426\" class=\"size-full wp-image-11303\" srcset=\"https:\/\/mathscitech.org\/articles\/wp-content\/uploads\/2024\/02\/screenshot.2765.png 661w, https:\/\/mathscitech.org\/articles\/wp-content\/uploads\/2024\/02\/screenshot.2765-300x193.png 300w, https:\/\/mathscitech.org\/articles\/wp-content\/uploads\/2024\/02\/screenshot.2765-150x97.png 150w, https:\/\/mathscitech.org\/articles\/wp-content\/uploads\/2024\/02\/screenshot.2765-400x258.png 400w\" sizes=\"auto, (max-width: 661px) 100vw, 661px\" \/><\/a><p id=\"caption-attachment-11303\" class=\"wp-caption-text\">There are 4 action types in a row of the recorded macro, each with various parameters.<\/p><\/div><\/p>\n<p><strong>Reference 3: <a href=\"https:\/\/github.com\/notepad-plus-plus\/notepad-plus-plus\/blob\/master\/scintilla\/include\/Scintilla.h\" rel=\"noopener\" target=\"_blank\">Searchable list of Scintilla messages<\/a><\/strong><\/p>\n<p><strong>Reference 4: <a href=\"https:\/\/github.com\/npp-community\/nppcr_npp\/blob\/master\/PowerEditor\/src\/menuCmdID.h\" rel=\"noopener\" target=\"_blank\">Searchable list of Notepad++ Menu Command IDs<\/a><\/strong><br \/>\nFor reference, Notepad++ Command IDs are referenced off the following base numbers:<br \/>\n        WM_USER=1024<br \/>\n        NPPMSG=2024<br \/>\n        IDM 40000<br \/>\n        File Menu commands are IDM+1000<br \/>\n        Edit Menu commands are IDM+2000<br \/>\n        Search Menu commands are IDM+3000<br \/>\n        View Menu commands are IDM+4000<br \/>\n        Format Menu commands are IDM+5000<br \/>\n        Language Menu commands are IDM+6000<br \/>\n        About Menu commands are IDM+7000<br \/>\n        Settings Menu commands are IDM+8000<br \/>\n        Execute Menu commands are IDM+9000<br \/>\n        System Tray Notifications are IDM+3100<\/p>\n<p>The full list of individual commands is <a href=\"https:\/\/github.com\/npp-community\/nppcr_npp\/blob\/master\/PowerEditor\/src\/menuCmdID.h\" rel=\"noopener\" target=\"_blank\">here<\/a>, courtesy of the NppExec plugin.<\/p>\n<p>The <a href=\"https:\/\/github.com\/notepad-plus-plus\/notepad-plus-plus\/blob\/master\/PowerEditor\/src\/MISC\/PluginsManager\/Notepad_plus_msgs.h\" rel=\"noopener\" target=\"_blank\">messages file is here<\/a>.<\/p>\n<hr\/>\n<p><em>Stay tuned for further articles in this series describing software tools I use to speed things up and build working prototypes fast.<\/em><\/p>\n<p>Articles in this series:<\/p>\n<ol>\n<li><a href=\"https:\/\/mathscitech.org\/articles\/software-force-multiplier\" target=\"_blank\" rel=\"noopener noreferrer\">Efficient Computing: using Software as a &#8220;Force-Multiplier&#8221;<\/a><\/li>\n<li><a href=\"https:\/\/mathscitech.org\/articles\/totcmd\" target=\"_blank\" rel=\"noopener noreferrer\">Total Commander (TC): a powerful two-panel file manager (&#8220;why explore when you can command?&#8221;)<\/a><\/li>\n<li><a href=\"https:\/\/mathscitech.org\/articles\/npp\" target=\"_blank\" rel=\"noopener noreferrer\">Notepad++ (NPP): a programmer&#8217;s text editor.<\/a><\/li>\n<li><a href=\"https:\/\/mathscitech.org\/articles\/search-everything\" target=\"_blank\" rel=\"noopener noreferrer\">Everything: an ultra-fast desktop search engine.<\/a><\/li>\n<\/ol>\n<p>Richard Hamming (Applied Mathematician)<\/p>\n<blockquote><p>&#8220;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 &#8212; it is very much like compound interest.&#8221; &#8211; Richard Hamming, <a href=\"https:\/\/www.holoborodko.com\/pavel\/wp-content\/plugins\/download-monitor\/download.php?id=16\">You and Your Research<\/a><\/p><\/blockquote>\n<hr \/>\n<div class='footnotes' id='footnotes-3268'>\n<div class='footnotedivider'><\/div>\n<ol>\n<li id='fn-3268-1'> You don&#8217;t want to overwrite your current instance, as capabilities are dependent on version of the plugin, and yours may be different than mine. <span class='footnotereverse'><a href='#fnref-3268-1'>&#8617;<\/a><\/span><\/li>\n<\/ol>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>If you haven&#8217;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.<\/p>\n<\/p>\n<p> 1. Notepad++: a programmable, extensible, feature-rich text editor <\/p>\n<p>NotePad++ (NPP) is an open-source programmer&#8217;s text editor with outstanding built-in features that can be further enhanced with powerful plugins [Read More&#8230;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"nf_dc_page":"","footnotes":""},"categories":[9,120,18,100],"tags":[125,171,177],"coauthors":[112],"class_list":["post-3268","post","type-post","status-publish","format-standard","hentry","category-mathtools","category-software-engineering","category-programming","category-softwaretools","tag-programming","tag-total-commander","tag-utilities","odd"],"views":16991,"_links":{"self":[{"href":"https:\/\/mathscitech.org\/articles\/wp-json\/wp\/v2\/posts\/3268","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mathscitech.org\/articles\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mathscitech.org\/articles\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mathscitech.org\/articles\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mathscitech.org\/articles\/wp-json\/wp\/v2\/comments?post=3268"}],"version-history":[{"count":68,"href":"https:\/\/mathscitech.org\/articles\/wp-json\/wp\/v2\/posts\/3268\/revisions"}],"predecessor-version":[{"id":11621,"href":"https:\/\/mathscitech.org\/articles\/wp-json\/wp\/v2\/posts\/3268\/revisions\/11621"}],"wp:attachment":[{"href":"https:\/\/mathscitech.org\/articles\/wp-json\/wp\/v2\/media?parent=3268"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mathscitech.org\/articles\/wp-json\/wp\/v2\/categories?post=3268"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mathscitech.org\/articles\/wp-json\/wp\/v2\/tags?post=3268"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/mathscitech.org\/articles\/wp-json\/wp\/v2\/coauthors?post=3268"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}