In Notepad++, how can I insert the current date and time? - datetime

On Windows Notepad.exe, I simply press F5 and it inserts the date and time like this:
11:05 AM 1/14/2015
Can I add similarly simple functionality to Notepad++?

If your Notepad++ shipped with TextFX, you can find this in TextFX > TextFX Insert > Date & Time - short format, which will insert a string in the exact same format. If you don't see a TextFX menu, install it via the plugin manager and it will appear.
You can then bind it to a keyboard shortcut in Settings > Shortcut Mapper... > Plugin Commands. Look for I:Date & Time - short format in the mappings.

Step 1 : Install plugin TextFX
Step 2 : Insert Date & time

Try "Python Script" plugin
I prefer to use the Python Script plugin as documented here: https://ardamis.com/2014/03/09/adding-an-insert-datestamp-or-timestamp-macro-to-notepad-plus-plus/
because it gives me total control over how I want to the datetime stamp formatting to look, and it also allows me to create macro scripts for inserting other types of values that I want to compute.
Install "Python Script" MANUALLY
Please note that you must download the Python Script plugin from http://npppythonscript.sourceforge.net/download.shtml because downloading it from the Plugin Manager in Notepad++ doesn't always work. (See this thread for details.)
Write "Time.py" script
Then you can write a simple script like this:
import time
# import sys
timeStr = time.strftime( '%Y-%m-%d' + ' # ' + '%I:%M %p' )
# sys.stdout.write(timeStr)
editor.addText( timeStr )
You can change the format string as you wish. This allows you to have total control over the text output. (See Python 2's time.strftime documentation for details.)
Then save the script to this filename:
"%AppData%\Notepad++\plugins\Config\PythonScript\scripts\Time.py"
Create "menu item" inside "Python Script"
Navigate here: Menu bar -> Plugins -> Python Script -> Configuration like this:
Then you can add the script like this:
Assign hotkey
Then, when you restart Notepad++, you can assign the script to a shortcut like this by going to Menu bar -> Settings -> Shortcut Mapper -> Plugin Commands -> Time:
Further reading
More documentation on the Python Script plugin is available here: PythonScript plugin documentation for Notepad++

This features has been added in Notepad++ v8.1.4.
Menu > Edit > Insert >
Date Time (short)
Date Time (long)
That answers this question without the need for a plugin.
Can you find a way to map it to a shortcut? Currently, the shortcut mapper does not have an entry to map it to. When I try to record and playback a macro for it, I get gibberish on the screen (looks like a bug).

It looks like the TextFX plugin proposed here is not available for 64bit any more.
The alternative as of today is to install the Notepad++ Plugin Demo plugin, which provides Date Time - short format and Date Time - long format. Map to shortcuts as desired. In my German locale, the results are, respectively:
12:10 01.07.2020
12:10 Mittwoch, 1. Juli 2020

With the TextFx add on there's an option to insert date and time. I guess you can assign a keyboard shortcut to it.

A simple method through LuaScript (https://github.com/notepad-plus-plus/notepad-plus-plus/issues/497 and https://www.lua.org/pil/22.1.html): install LuaScript plugin first, then in LuaScript Edit Startup Script past the following:
npp.AddShortcut("Insert Current Date/Time", "Ctrl+Shift+D", function()
editor:ReplaceSel(os.date("%I:%M %p %m/%d/%Y"))
end)
After restart npp, the Ctrl-Shift-D will do as F5 in notepad.

Starting with Notepad++ 8.1.5, you can insert a custom date/time format using Edit/Insert/Date Time (customized). You can customize it in Settings/Preferences/Multi-Instance & Date.

In one of the recent N++ updates, my previous shortcut of CTRL + SHIFT + D, stopped working. I then rechecked and had to remap the custom date shortcut to ALT+ SHIFT + D. This is how it looks:
Make sure your customized date match your expectations:

A more generic answer using "Autohotkey":
https://autohotkey.com/board/topic/21387-how-to-insert-current-date-into-a-hotkey/
Examples:
;//will replace ddd keystroke with yyyy-MM-dd formatted date
:R*?:ddd:
FormatTime, CurrentDateTime,, yyyy-MM-dd
SendInput %CurrentDateTime%
return
;//will replace ttt keystroke with yyyy-MM-dd HH:mm formatted date/time
:R*?:ttt::
FormatTime, CurrentDateTime,, yyyy-MM-dd HH:mm
SendInput %CurrentDateTime%
return

Here's an easy and flexible way to insert a date/time stamp in any format you like.
Like many other developers, I used the FingerText plugin which allows you to insert customizable snippets of code or text by typing a "trigger" word and pressing the tab key.
One of my snippets is to insert a date/time stamp that I use in code comments:
I just type stamptab and it inserts a date like this: 2020-07-31 # 11:45
Here is the FingerText code I use to generate the stamp, which you can modify for any datetime format you choose:
$[![(key)DATE:yyyy-MM-dd]!] # $[![(key)TIME:HH:mm]!] $[0[]0][>END<]
You can download FingerText through the Plugins Admin dialog.

The quickest way that comes to my mind is to open Windows Notepad, press F5, copy/paste. No need to install anything...

Related

How to search previously executed commands in the Julia REPL?

Is there a quick way to search old commands which were run in the Julia REPL? Using the up arrow to go back in time seems to have a limit on its history and it is also quite cumbersome.
One of the five REPL models available in Julia is the "Search mode" which allows you to search through previously executed commands from the REPL. You can click "Control" + "r" to open search mode like is shown below:
(reverse-i-search)`':
There is also a forward search available with "Control" + "s". You can read more about Julia's REPL Search mode here: https://docs.julialang.org/en/v1/stdlib/REPL/#Search-modes
In addition to "real" search, you can also enter the beginning of a previous line and scroll up in the history (using ↑ or Ctrl-P) to switch between all previously entered lines starting with the same prefix.
So, if you had previously entered x = some_complicated_expression, you can write x = and go up until the line you were looking for appears.
Checkout: https://kristofferc.github.io/OhMyREPL.jl/latest/features/fzf/#Fuzzy-REPL-history-search
Which will be easier to use than reverse-i-search

Modify or hook into Jupyter's tab completion

I was wondering if there was a way to modify Jupyter Lab or Notebook's tab-complete functionality. For example, if I type "\alpha", and then press the tab key, I will get the UTF-8 character "α" in the cell.
Is there any way that I can do a custom "[string without spaces]" to tab-complete into some specific UTF-8 character or string?
e.g. "\implies" + tab -> "⇒"
I can see a large number of use cases for this in my programming life, so I was wondering if Jupyter (Lab or Notebook) offered the ability to modify some settings (or load in a file) that maps strings to a tabbed output. Or is there a different idea that you could use to implement this?
Thanks!
Jupyter is (based on) IPython and it's completion engine - we can make use of it.
Update: you can override latex_symbols dict to get the behavior you want:
from IPython.core.latex_symbols import latex_symbols
latex_symbols['\\implies'] = '⇒'
You should be able to build upon this example to make it work with a whole range of characters.
Initial answer/another solution: you can hook into IPython completers, though it would not work exactly as you wish: it won't replace the text, but just append a special character. Here is an example:
from IPython import get_ipython
def implies_competer(ipython, event):
return ['⇒']
ipython = get_ipython()
ipython.set_hook('complete_command', implies_competer, re_key='.*implies')
Then when you type (the space after the keyword is important):
and then press tab, you will get:

create multicursor in Atom

I use Atom on Ubuntu 17.10 with wayland window manager.
I can create multiple cursors with CTRL+Mousclick or with CTRL+d to select the next same string.
But how can I for example mark some lines and create a cursor at the start of each line?
Also would be great to use search and find-all to select lots of results in a text to create a cursor at all these results.
I used this workaround at the moment by selecting the line-break and use CTRL+d to select the next linebreaks too with extra cursors, then go one left and Pos1 to have the cursors at the start of each line.
I wanted to select a string that repeats about 200 times in a dataset of 3000 text-blocks in a bunch of output and then I wanted to expand the selection to each of those blocks. That would have been really easy with multiple cursors. I solved this another way now, but for the next time I would like to see a complete instruction manual about how to create multiple cursors in the standard atom setting. I couldn't find this. Search-engines give me lots of plugins and solutions in different multicursor plugins.
I found the manual that explains it like in sublime (ctrl alt up and down):
Alt+Shift+Up and Down
see: https://flight-manual.atom.io/using-atom/sections/editing-and-deleting-text/#multiple-cursors-and-selections
What is missing in the manual is also a useful option:
use "find all" with the search tool in Atom (CTRL+F)
press Alt + Enter to create cursors at all the found locations.
see: https://discuss.atom.io/t/how-do-i-create-multiple-cursors-from-search-result/53231/5
I wanted to make it easy so I could just use alt+⬇️ or alt+⬆️ to have multiple cursors. This was my solution and I think its the easiest:
# From Atom -> Keymap add the following lines:
'.editor':
'alt-up': 'editor:add-selection-above'
'alt-down': 'editor:add-selection-below'

Keyboard shortcut for inserting roxygen #' comment start

This question might be over-answered but I could not find one. Basically I am using RStudio and the keyboard shortcut cmd + shift + c for inserting comments. Is there an other combination to insert directly the roxygen tags #' ? Or a way to modify RStudio to tell it to add the ' when I press cmd + shift + c?
You could use an RStudio addin, you'll need a fairly recent version of RStudio. I've just created an RStudio addin that comments/uncomments using roxygen2 tags, i.e. works just like code commenting, but with #'. The addin is hosted on github.
Just install and attach a convenient keyboard shortcut.
If you are interested in other available addins, see the addinmanager addin.
This isn't exactly what you're looking for. But you can add an ROxygen2 skeleton for a function by placing your cursor inside the function then pressing ctr+alt+shift+R. Then if you hit enter in the ROxygen2 codeblock it will automatically add the backtick. So an alternate workflow, edit the function, then insert the skeleton and do the documentation that way.
Rstudio find/replace
Select text to comment out, tick regex option and specify:
find: ^(.+)
replace: #' \1
Above means to find all characters (.+) following beginning of the line ^ and replace them by the #' and the first captured group \1.
vim find/replace
I find this option the easiest as I use Rstudio in vim mode. To replace text one only need to:
select text
go to the "command-line mode" by using : key
enter s/^/#' and hit enter.
s/ stands for "substitute", ^ stands for beginning of the line and #' is the text we are inserting.
This is not a default Rstudio option. Make sure you have Keybindings set to "vim" in RStudio "Global Options"
The absolute simplest answer is in the comments on the addins answer above and deserves its own billing (with attribution):
Rstudio does have column selection, to get multiple cursors alt + mouse to select, or ctrl + alt and the arrow keys, then keys move forward and back by words/lines work as expected. – Peter Apr 16 '16 at 23:55
[ETA: On Mac, ctrl + option + arrow keys or option + mouse.]
#Peter nice. in that case you could just make a chunk of cursors at the beginning of the line and and type in #' . I doubt roxygen comments are used enough to warrant a dedicated keyboard shortcut, but it wouldn't hurt to have I guess – rawr Apr 17 '16 at 1:26

TeamCity Current Date variable in MMdd format

In TeamCity is there an easy way to get a variable for the current date in the format MMdd (eg 0811 for 8-Aug)?
My google-fu did not turn up an existing plugins. I looked into writing a plugin, but not having a jdk installed, that looks time consuming.
This is quite easy to do with a PowerShell build step (no plugin required) using the following source code:
echo "##teamcity[setParameter name='env.BUILD_START_TIME' value='$([DateTime]::Now)']"
or (for UTC):
echo "##teamcity[setParameter name='env.BUILD_START_TIME' value='$([DateTime]::UtcNow)']"
This uses TeamCity's Service Message feature that allows you to interact with the build engine at runtime e.g. set build parameters.
You can then reference this build parameter from other places in TeamCity using the syntax %env.BUILD_START_TIME%
The advantage of this approach is you don't need to use a plugin. The disadvantage is you need to introduce a build step.
For Unix based build agents I propose next custom script as one of build commands:
export current_build_date_format="+%%Y.%%m.%%d"
export current_build_date="$(date $current_build_date_format)"
echo "##teamcity[setParameter name='env.current_build_date' value='$current_build_date']"
You have to make double % sign to avoid interpretation for date executable command line argument FORMAT string (see %Y.%m.%d) as already existing TeamCity variable.
The Groovy Plugin for TeamCity provides build start date/time properties:
Provides build properties:
system.build.start.date / env.BUILD_START_DATE
system.build.start.time / env.BUILD_START_TIME
This blog post has installation / configuration instructions for the Groovy plugin, as well an example of customizing the date/time format.
You can also try Date Build Number plug-in. It povides additional var in build number format rather than build property.
Similar to the Date Build Number plugin mentioned in this answer, there exists a derived plugin called Formatted Date Parameter. It provides a customizable parameter build.formatted.timestamp that can be used out of the box in fields or other parameters. No need for a separate build step.
An old question, but for those looking for a solution now there is a system parameter available.
system.buildStartTime
You need to declare it in config (it's not available until runtime) in order to run. I set mine to value [Filled Automatically]
As you can guess, this time is set to the build start time, so that may not be ideal for some needs. But it's easy and reliable.
To add a dated folder to my build in TeamCity I added the following to my custom script. What had me stuck was the double % sign in the date string. D'oh
TARGET_DIR=/Users/admin/build/daily
TARGET=$(date "+%%Y-%%m-%%d")
if [ ! -d ${TARGET_DIR} ]; then
mkdir -vp ${TARGET_DIR}/
fi
mv -v build.dmg ${TARGET_DIR}/build_${TARGET}.dmg
If you only want to have one-line bash command in a build step, just use as below.
echo "##teamcity[setParameter name='build.timestamp' value='$(date +%%m%%d)']"
(double % symbol is for TeamCity own escape rule to use % character)
It will set a MMdd parameter value right after the execution during runtime so very useful to put at any build step. Then, you can retrieve a parameter value afterward.
Note that you should create build.timestamp parameter firstly to TeamCity project.
A step further, I made a simple bash script to have bash date format timestamp. This script will set timestamp to whatever bash supported datetime format and parameter name to TeamCity.
name="" # TeamCity parameter name
format="%Y-%m-%dT%H:%M:%S%z" # ISO8601 format by default
result="" # a TeamCity parameter value to be set
for ARGUMENT in "$#"
do
KEY=$(echo "$ARGUMENT" | cut -f1 -d=)
VALUE=$(echo "$ARGUMENT" | cut -f2 -d=)
case "$KEY" in
name) name=${VALUE} ;;
format) format=${VALUE} ;;
*)
esac
done
result=$(date "+$format")
echo "##teamcity[setParameter name='$name' value='$result']"
Below usage will set ISO8601 format timestamp to build.timestamp parameter.
./teamcity_datetime.sh name=build.timestamp
If you want to set only MMdd, the execution could be as below.
./teamcity_datetime.sh name=build.timestamp format="%%m%%d"

Resources