5
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

vimで5分後の時刻を挿入する

Posted at

やりたかったこと

入力:Ctrl + S
出力:2024/09/13(Fri) 09:00

解決方法

~/.vimrcに下記追加

nmap <silent> <C-S> <ESC>i<C-R>=strftime("%Y/%m/%d(%a) %H:%M", localtime() + 300)<CR><CR><ESC>

目的

日報に記入する現在時刻を毎回打つのが面倒なので一発で入力したかった。

なぜ5分後?

丸め処理を行おうとして
2024/09/13(Fri) 08:59
の最後でインクリメント(Ctrl+A)しても
2024/09/13(Fri) 08:60
となってしまう。

そこで予め5分後を出力しておき
2024/09/13(Fri) 09:04
からデクリメント4回(4+Ctrl+X)したほうが楽だった。

参考

https://hyuki.hatenablog.com/entry/20130714/vim
https://nanasi.jp/articles/code/date/localtime.html

5
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?