From 1e97570f54c86a9238baf4bb4eb3a82e6f3874a9 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Fri, 1 Oct 2021 21:49:26 +0200 Subject: Create 'date' plugin Add a command to insert the current date after point. Saves me a bit of typing, as well as effort remembering the current date. --- bundle/date/autoload/date.vim | 12 ++++++++++++ bundle/date/plugin/date.vim | 6 ++++++ 2 files changed, 18 insertions(+) create mode 100644 bundle/date/autoload/date.vim create mode 100644 bundle/date/plugin/date.vim (limited to 'bundle') diff --git a/bundle/date/autoload/date.vim b/bundle/date/autoload/date.vim new file mode 100644 index 0000000..3c86507 --- /dev/null +++ b/bundle/date/autoload/date.vim @@ -0,0 +1,12 @@ +" Insert the current date in the format "2021.10.01" after the cursor. +function! date#Insert(separator) + let separator = '.' + + if a:separator != '' + let separator = a:separator + endif + + let date = strftime('%Y' . separator . '%m' . separator . '%d') + + execute 'normal! a' . date . "\" +endfunction diff --git a/bundle/date/plugin/date.vim b/bundle/date/plugin/date.vim new file mode 100644 index 0000000..a03ce22 --- /dev/null +++ b/bundle/date/plugin/date.vim @@ -0,0 +1,6 @@ +if exists('g:loaded_date') + finish +endif +let g:loaded_date = 1 + +command! -nargs=? DateInsert call date#Insert() -- cgit v1.2.3