VIM格式打印日期到当前文件

发布于 2025-02-07 23:00:39 字数 384 浏览 1 评论 0原文

我试图将2022年1月1日星期一格式的当前格式打印到我当前的VIM文件中。到目前为止,我已经尝试了以下命令,但是符号作为当前文件放入命令中。

:0r !date '+%a, %d %b %Y'

最终为我提供了类似于下面的输出。

/home/user/file.txta, /home/user/file.txtd /home/user/fileb /home/user/fileY

问题在于,像VIM一样,为设置了当前文件的路径,但这导致了当前用例的问题。

任何帮助都将受到赞赏

I am trying to print the current formatted as Mon, 1 Jan 2022 into my current file in vim. So far I've tried the following command, but the % sign gets put into the command as the current file.

:0r !date '+%a, %d %b %Y'

This ends up giving me an output similar to seen below.

/home/user/file.txta, /home/user/file.txtd /home/user/fileb /home/user/fileY

The issue is that the path to the current file is put in place for % as vim does, but that is causing issues for the current use case.

Any help is appreciated

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

海之角 2025-02-14 23:00:39

直接解决方案显然是要逃脱

:0r !date '+\%a, \%d \%b \%Y'

但是您可能对内置的:help strftime()不需要逃脱:

:0put=strftime('%a, %d %b %Y')

The immediate solution is obviously to escape the %:

:0r !date '+\%a, \%d \%b \%Y'

But you might be interested by the built-in :help strftime(), which doesn't require escaping:

:0put=strftime('%a, %d %b %Y')
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文