gpt4 book ai didi

vim - 在当前行中的一些词后插入时间戳?

转载 作者:行者123 更新时间:2023-12-05 09:19:13 25 4
gpt4 key购买 nike

我想在当前行中插入时间戳而不破坏该行中的内容。我读过这个post .基本上它建议:1)。 !r date 插入下一行; 2). !!date 清除当前行并插入时间戳。

最佳答案

您所要做的就是映射F3:

inoremap <special> <F3> <c-r>=strftime('%c')<CR>

通过这种方式,每当您按下 F3 按钮时,它都会在插入模式期间在当前位置插入时间戳。


说明:

[i][noremap] [<special>] [<F3>] [<c-r>=strftime('%c')<CR>]
| | | | |
| | | | |
| | | | |---> Whenever you press <F3> button it
| | | | |---> will execute this part
| | | | |---> it is like pressing ctrl-r
| | | | |---> then pressing = and typing
| | | | |---> strftime('%c') and then
| | | | |---> typing enter (<cr>) for execution
| | | |
| | | |---> The key that you want to map
| | |
| | |----> This argument is for avoiding side effect of 'cpoption'
| |
| |-----> The mapping (noremap) is not recursive
| |
| |-----> It means that it doesn't care about other mappings
|
|---------> (i) for insert-mode (n) for normal-mode (c) for command-mode ...

有关更多信息,请参阅 :help map.txt

关于vim - 在当前行中的一些词后插入时间戳?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41518011/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com