vim-insert-timestamp is a vim plugin to easily input datetime timestamps (with previewing) based on natural language processing.
Here is an example of vim-insert-timestamp in action!
vim-insert-timestamp uses python3 and parsedatetime, so be sure to have them installed:
pip3 install parsedatetime
To support timezone printing as well, also install tzlocal:
pip3 install tzlocal
Then, install vim-insert-timestamp using either
pathogen or
vundle. For example, for vundle, add
the following lines to your ~/.vimrc
:
Plugin 'alkim0/vim-insert-timestamp'
Then enable the plugin with the following line in your ~/.vimrc
:
call InsertTimestampEnable()
I like to only enable it for vimwiki files, so I use:
autocmd FileType vimwiki call InsertTimestampEnable()
The g:insert_timestamp_start_key
variable controls which key combination
you want to use to start the timestamp insertion. By default, this is
<C-l>
.
The g:insert_timestamp_complete_key
variable controls which key combination
you want to use to complete to the current previewd timestamp. By default, this
is <Tab>
.
Note for vimwiki, <Tab>
is already used to jump from table cell to table
cell, so you may need to remap your completion key. I use:
let g:insert_timestamp_complete_key = "'"
If you want to enable also printing out the current timezone with the timestamp, set
let g:insert_timestamp_enable_timezone = 1
After you have enabled vim-insert-timestamp. Go into insert mode, and press
<C-l>
(or whatever you configured to). A preview window will pop up, and as
you type more details, the previewd timestamp will be refined. To complete to
the currently previewed timestamp, press <Tab>
(or whatever you configured
it to). To get out of insert timestamp mode, either press <C-l>
again or
<Esc>
.
vim-insert-timestamp outputs the timestamp in a format similar to Emacs's org-mode. It can output both individual timestamps and timestamp ranges.