Thursday, September 12, 2013

Preserving contents of a register in vimscript

Is it possible to preserve a register in vimscript while I do some work? I know I can do

:let saved_a = @a
...
: let @a = saved_a

to preserve the text in the register. And if that text ends with a CR or LF, when it's restored it will be restored as a linewise selection, otherwise a characterwise one.

But is it possible to preserve content that is blockwise? Suppose I select a chunk of text using Ctrl-V and then do "ay. If I do the above, then paste, it will be pasted characterwise rather than blockwise.

I'm trying to write a script that uses a couple of registers, and I want to avoid trashing them. I could just say register z (say) is reserved for my script, but I'd rather not do that if I can avoid it...

Thanks,
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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

No comments: