Kudos
I’ve been keeping some form of a work journal for years; I’d highly recommend it. I recently got annoyed with creating timestamps in Notepad++, and ran across a helpful post in a forum. It was so helpful that I thought I’d do my best to try to give it some additional street cred.Here is the original link:
http://sourceforge.net/p/notepad-plus/discussion/331753/thread/3458d1da#62f2
What day of the week was 4/22/2006 anyway?
Before I start, if you have the TextFX plugin already setup in Notepad++, it provides 2 static methods of inserting a datetime stamp:Menu: TextFX > TextFX Insert > I:Date & Time: short format: 3:56 PM 3/22/2013
Menu: TextFX > TextFX Insert > I:Date & Time: long format: 3:56 PM Friday, March 22, 2013
If these look good enough to you, you can skip to the section on how to map a keyboard shortcut to these. However, in addition to the time and date, I also wanted the day of the week, like this: 03:36 PM 03/22/2013 (Friday)
Steps
It turns out this can easily be done with a simple Python script. I don’t even know Python that well and I was able to do it.1. Install the python plugin:
- The plugin’s name is: Python Script
- It’s recommend you do this via the NP++ Plugin Manger (Menu: Plugins > Plugin Manger)
- Here’s a link to the project page: http://npppythonscript.sourceforge.net/
- The script includes some basic Python libraries, so you shouldn’t need to install Python or other 3rd party libraries
2. Setup script in Notepad++:
- Menu: Plugins > Python Script > New Python Script
- It will ask you for a new file name, I choose: npp_timedate_stamp.py
- A new tab will appear in NP++ for you to enter the script.
- This is the script I used:
# Add date/time stamp in Notepad++ 03:28 PM 03-22-2013 (Friday) import time editor.addText( time.strftime( '%I:%M %p %m/%d/%Y (%A) ' ) )
- Here is a link to the Python documentation which shows what all the format string characters: http://docs.python.org/2/library/time.html
- Save your script
3. Configure Notepad++ to use the script:
- Menu: Plugins > Python Script > Configuration
- You should see your script under the User Scripts section
- Add it to Toolbar and/or Menu
- I put it in both, but I only managed to find it under menu
- It shows up as its own entry under Menu: Plugins > Python Script > npp_timedate_stamp
4. Create a keyboard shortcut (my preferred method):
- Menu: Settings > Shortcut Mapper
- Switch to Plugin
- Scroll down until you see your script name (i.e. npp_timedate_stamp)
- Click on it, choose Modify, and choose a key. I used: CTRL + ;