Saturday, March 3, 2012

Re: How to clear number registers

howard Schwartz <howardb21@gmail.com> a écrit:
>
> Hi,
>
> I want to set the contents of the numbered registers ( 1-9) to nothing, each
> time I enter a buffer. Thus only yanks and deletes done in the current buffer
> will make their way into numbered registers. To this end, I put the following
> autocommand in my .vimrc file:
>
> au BufRead * for i in range(1,9) | let @i = "" | endfor
>
> Tha shoud let @1 = "" and @2 = "" and so on. But the i variable never iterates
> to numbers. Instead this line just sets the register named, i, to nothing.
> I've tried quoting i, using eval etc. Always, the i is not evaluated as a
> number in the let statements. I must be doing something simple wrong?

You should use ":exe[cute]":

au BufRead * for i in range(1,9) | exe "let @" . i . " = ''" | endfor

That (extremely useful) command executes a string as if it was fed to Vim.

Best,
Paul

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

No comments: