如何有效清除vim寄存器?

编程入门 行业动态 更新时间:2024-10-25 13:17:46
本文介绍了如何有效清除vim寄存器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

vim 中的寄存器是一个很棒的功能,可以存储文本片段,甚至可以对存储在其中的文本运行命令.不过,我是个很整洁的人,做完后会收拾东西.

Registers in vim are a great feature to store text snippets and even to run commands on the text stored within them. However, I'm a tidy person and tend to clean things up when I'm done.

我知道如果我想清除寄存器 a,我可以使用 qaq.

I know that if I wanted to clear register a, I can use qaq.

我也可以执行以下命令:

I can also execute the following command:

:let @a = ''

然而,这些解决方案似乎只是解决问题的方法.当我执行 :registers 时,列表仍然显示 register a(具有空值),而不会显示从未使用过的寄存器.

However, these solutions seem like a mere workaround to the problem. When I execute :registers, the list still displays register a (with an empty value), while registers that have otherwise never been used are not displayed.

有没有办法清除一个具有从该列表中删除寄存器的副作用的寄存器?

Is there a way to clear a register with the side-effect of removing the register from this list?

如果是这样,是否还有一种方法可以一次清除所有寄存器,即重置该寄存器列表?

And if so, is there also a way to clear all registers at once, i.e., to reset that list of registers?

推荐答案

由于邮件列表中的那个古老的答案,由 @romainl 链接,我们有 setreg('a', []) 清除寄存器.

Since that venerable answer on the mailing list, linked by @romainl, we have setreg('a', []) that clears the register.

因此,代码可以变成:

let regs=split('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789/-"', '\zs')
for r in regs
  call setreg(r, [])
endfor

这篇关于如何有效清除vim寄存器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

更多推荐

[db:关键词]

本文发布于:2023-04-27 17:49:48,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1159834.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:寄存器   vim

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!