Monday, June 12, 2017

Re: save and load a micro

2017-06-12 8:05 GMT+03:00 Ben Fritz <fritzophrenic@gmail.com>:
> On Sunday, June 11, 2017 at 5:26:43 AM UTC-5, Sand Glass wrote:
>> And record a macro in register a. But the macro not completely right like ^Q(it's into block coloumn mode). I want to fix my macro and save it to a file, next time I open a file can load the macro to a reg.
>> The question is I don't how to fix my macro and load it to a reg next time.
>
> By default, it should be saved already, in your .viminfo file. Check your 'viminfo' setting to make sure if you are worried.
>
> You can also paste the contents of your register into a file with this normal-mode command:
>
> "ap
>
> Then you can save that file if you like. To get your macro back, just yank the content back into a register:
>
> 0"ay$
>
> This may not work in all cases for special characters in the register, etc. The .viminfo method is probably more robust.

For robust keeping register in a file one should use
`writefile([getregtype('a')] + getreg('a', 1, 1), 'rega', 'b')`. For
restoring then: `let rega = readfile('rega', 'b') | setreg('a',
rega[1:], rega[0])`.

>
> --
> --
> 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/d/optout.

--
--
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/d/optout.

No comments:

Post a Comment