AFAIK 您不能使用内置命令/函数使寄存器从列表中消失。这似乎只有通过将它们从您~/.viminfo
的听起来有点极端的方法中删除才能实现。
vim 邮件列表上的这个线程有一个清除每个寄存器的命令,但它不会从以下位置删除它们:reg
:
let regs='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789/-"' | let i=0 | while (i<strlen(regs)) | exec 'let @'.regs[i].'=""' | let i=i+1 | endwhile | unlet regs
- - 编辑 - -
不再需要上面的命令,但这里是好奇的细分:
" The value of variable regs is a string made up of all named
" and numbered registers, plus the search, small delete, and
" unnamed registers. A string can be used as a list for our
" use case so we use the most concise method. We could have
" done let regs = ['a', 'b', 'c', etc. instead.
let regs = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789/-"'
" We are going to iterate through the string so we initialize
" a loop counter with value 0.
let i = 0
" Here is our loop where we check at each iteration if the loop
" counter is smaller than the length of regs.
while (i < strlen(regs))
" If it is, we programmatically assign an empty string
" to each corresponding register
exec 'let @' . regs[i] . ' = ""'
" and we add 1 to the loop counter.
let i = i + 1
endwhile
" Once we are done, we get rid of the variable we created above
" which is now unnecessary.
unlet regs