Adding an insert datestamp or timestamp macro to Notepad++

I had been looking off and on for a few years for a way to insert a timestamp into a file in Notepad++, preferably by a hotkey. The no-longer-in-development TextFX plugin frequently comes up in Google searches as one way of doing this, but the plugin doesn’t offer any ability to customize the format of the date or time stamp.

I found this article: that explains, briefly, how to do this using the Python Script plugin. I’ve been curious about Python for awhile, too, so I was willing to give it a shot. The SourceForge project page for Python Script is at

So, here’s a quick tutorial on adding a customizable insert datestamp/timestamp macro to Notepad++.

Download the Python Script plugin from and install it. Do not download it from within Notepad++ by clicking Plugins | Plugin Manager | Show Plugin Manager, scrolling down the Available plugins list to Python Script, checking the box and clicking Install, because it just won’t work (and you may get an older version of the plugin).

Restart Notepad++ and you’ll find that Python Script has been added to the Plugins menu.

To create the script that will insert the timestamp, click Plugins | Python Script | New Script. Enter a filename for the script file you are about to create, like “”, and click Save.

A new, blank tab will appear in Notepad++. Paste in the following text:

import time 
editor.addText( time.strftime( '%Y-%m-%d %I:%M %p' ) )

Save the file to the default location in your user profile.

Add the script to Notepad++ by clicking on Plugins | Python Script | Configuration, highlighting, clicking the Add button above Menu items, and then clicking OK.

But, you probably want to be able to run this as a macro from a keyboard shortcut. Close the tab and then exit and relaunch Notepad++. Click on Settings | Shortcut Mapper… and choose the Plugin commands tab. The Time script should be listed here somewhere (in my case, it is usually somewhere around number 27). Highlight it, click Modify and assign it to a shortcut.

I choose to map my Time script to F5, because this mirrors the timestamp functionality built into Windows notepad.exe, but Notepad++ already uses that keystroke for the Run command. I never use the Run command, so I just remove the shortcut from that command by clicking on Settings | Shortcut Mapper… and choosing the Main menu tab, scrolling down to the Run item and either removing the mapping by changing the shortcut to None or changing it to something else, such as Ctrl+F5. For me, Run was located in the Shortcut mapper under Main menu around number 208. Close the Shortcut Mapper and you’re ready to use your new timestamp hotkey.

You can change the datetime formatting using variables! Just modify the contents of the file located at “%AppData%\Notepad++\plugins\Config\PythonScript\scripts”. See:

10 thoughts on “Adding an insert datestamp or timestamp macro to Notepad++

  1. Dude

    After updating to Notepad++ Python Script v1.0.8 it works now. This is a great tutorial and fixes the one thing about Notepad++ I had disliked since I started using it.

  2. Fedon

    You can install the “pork2sausage” plugin and define a command like this:
    [Insert CurrDate]
    progCmd=C:\cygwin\bin\bash.exe -c “echo -n $(date )”

    Note: Yes, I use Cygwin in my PC.

  3. Yuvraj

    If doesn’t show up in Shortcut Mapper, Go to Plugins > Python Script > Configuration
    Add to Menu Items, Change Initialisation to ATSTARTUP, Click Ok and Restart Notepad++

  4. Van

    I want to set shortcut of timestamp to Enter (hostkey) on Settings | Shortcut Mapper,
    but I can’t.
    On Shortcut Mapper, it only able set with Ctrl/Alt + Shift + Enter while my device sends Enter key.

    Who can show me the way to set shortcut to only Enter key

  5. James

    I have bookmarked this link and reference it about twice a year 😉
    At the time of writing, the Python Script Plugin in NPP Plugin Manager is out of date v1.0.6.0, and I find that it hast not worked with these instructions since some time in 2014. Instead, I upgrade to the latest Python Script Plugin v1.0.8.0 by downloading the MSI and installing directly from here:
    Then these instructions still work.
    Thanks for providing them!

Leave a Reply

Your email address will not be published. Required fields are marked *