Reputation: 6896
I'm just logging some work as I do it, each line being an action, I will be trying to do this every few minutes. Is there a trick way of inserting date/time something like:
14 June 2011 15:01:00 Downloaded source code from GIT
Would do fine... although thinking about it, inserting the date as I add a new line might be nice too..
Any other shortcuts that anyone else uses when trying to achieve similar would also be welcome.
(Win32, vim6.4)
EDIT
Here is what I ended up with: I type: appending 'vlog' then a space, like so
that was 30 minutes well spent vlog
and my log entry goes:
that was 30 minutes well spent
Jun-14 16:50
With me ready to type the next line, thats with With the .vimrc (_vimrc) entry:
"use this for file logging
:iab vlog <cr><c-r>=strftime("%b-%d %H:%M") <cr>
Cor! now lets get that 30 minutes back... cheers for the replies!
Upvotes: 5
Views: 3020
Reputation: 42225
I prefer to set an abbreviation for this like:
iab xdate <c-r>=strftime("%d/%m/%y %H:%M:%S")<cr>
So when I type "Downloaded source code on xdate"
, vim automatically expands the "xdate"
to "14/06/11 hrs:mins:secs"
. Being in insert mode and not having to disrupt my flow of typing to either get into normal mode or press a shortcut is useful at times. Also, you can set it to a shorter combination than "xdate"
if you so wish.
Upvotes: 12
Reputation: 45662
See here
Press F5 in normal mode or in insert mode to insert the current datestamp:
:nnoremap <F5> "=strftime("%c")<CR>P
:inoremap <F5> <C-R>=strftime("%c")<CR>
Upvotes: 3