How to clear vim registers effectively?

前端 未结 7 1256
傲寒
傲寒 2021-01-31 07:07

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

7条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-31 07:54

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

    Thus, the code could become:

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

提交回复
热议问题