Vim Gems

Small collections of tricky hacks.

Insert date- and timestamp

:nnoremap <F5> "=strftime("%c")<CR>P
:inoremap <F5> <C-R>=strftime("%c")<CR>
:iab <expr> DTS strftime("%c")

The first line is for the Normal mode. It places the time stamp in a register and pastes it at the cursor position when pressing F5. The second line is for the Insert mode (again on hitting F5) and the third line generates an expression that replaces the characters "DTS" to a timestamp. The selection of that expression is probably not the best idea, because while typing this text, I got the timestamp instead of the three letters D, T, S.

Source: Insert current date or time

social