将寄存器名称发送到映射命令

发布于 2025-01-23 13:58:58 字数 289 浏览 4 评论 0原文

我使此命令将我当前的缓冲区的文件路径发送到+寄存器:

:nmap <Leader>yp :let @+=expand("%:p")<cr>

我​​想将其扩展到它,以便用户选择呼叫&lt; leader&gt; yp时要发送的寄存器,但我不确定如何。

如果有一种“捕获所选寄存器”的方法,我可以将其使用到我的命令中,然后允许“ a&lt; leade&gt; yp之类的东西? 谢谢!

I made this command to send my current buffer's file path into the + register:

:nmap <Leader>yp :let @+=expand("%:p")<cr>

I'd like to extend it so that the user choose the register to send to when calling <Leader>yp, but I'm not sure how.

If there's a way to "capture the selected register", can I use it into my command to then allow something like "a<Leader>yp?
Thanks!

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

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

发布评论

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

评论(1

星星的軌跡 2025-01-30 13:58:58

多亏了Romainl的评论,我才能得出这个解决方案:

:nmap <Leader>yp :call setreg(v:register, expand("%:p"))<cr>

Thanks to romainl comment, I came to this solution:

:nmap <Leader>yp :call setreg(v:register, expand("%:p"))<cr>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文