Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

in vim how can you insert the current date/time into a note

What script might i use in (vanilla) Vim to insert a snippet with the current date and time into each and every new note generated.

like image 462
npr60 Avatar asked Dec 31 '22 22:12

npr60


2 Answers

You can use for example:

:pu=strftime('%c')

To put a timestamp into a file in the default timestamp format. The format is adjustable.

You could bind this action to a key (here F5 as an example). Put it to your .vimrc file without the colon in the beginning to make it permanent.

:nnoremap <F5> "=strftime("%c")<CR>P

More examples: https://vim.fandom.com/wiki/Insert_current_date_or_time

like image 196
Ultcyber Avatar answered Jan 05 '23 17:01

Ultcyber


In my case I have an insert abbreviation, so, wenever I am typing I just do 'idate'

inoreabbrev idate <C-R>=strftime("%b %d %Y %H:%M")<CR>

Just change the "strftime" to fit your needs

like image 20
SergioAraujo Avatar answered Jan 05 '23 16:01

SergioAraujo