每天一个vim小技巧[5] - 插入当前时间
strftime(FORMAT) returns the current time as string, formatted according to FORMAT.
strftime() can be given a second argument which is interpreted as a Unix time. In that case, strftime formats the point in time that the second argument refers to.
vimrc
To map an alias in INSERT mode:
iab: map an "alias" or say an "abbreviation"
" Add current time in INSERT MODE
" Example: 2023-03-22 23:09:43
iab <expr> dts strftime("%Y-%m-%d %H:%M:%S")
Append these lines to your vimrc.
Once you type dts and escape to NORMAL, the string dts will substituted to current date and time according your configuration. For more FORMAT information, refer to [^1].
Refs:
[1]. https://renenyffenegger.ch/notes/development/vim/script/vimscript/functions/strftime
浙公网安备 33010602011771号