Friday, May 28, 2021

Re: Where are vim macros stored

On 2021-05-28 11:10, Ruben Safir wrote:
> I just want to open the file and edit it.

Unless you have changed settings, it's stored in ~/.viminfo but it
can get overwritten upon quitting if you edit it while vim is
configured to (over)write it upon quitting. So if you plan to edit
it, you might want to

:set viminfo=

before quitting.

> Quoting back the manual for macros is significantly less polite in
> this context. If the manual and tutorials had what I wanted, or if
> I could discover the necessary file with find (and I don't know why
> that didn't work actually), I wouldn't have asked the question on
> the public mailing list. SO I asked specifically "where are they
> stored" They are stored in memory is sort of an answer.

The answers were an attempt to correct a misunderstanding that macros
were stored somewhere. Maybe they are, maybe they aren't. It
depends on your settings. So help-references were provided to arm
you with the understanding of how the pieces fit together.

Macros are not anything special. Just a register. Same as where you
yank/delete to and put from. Those are stored in memory.

Vim offers settings to control *if* those registers are then stored.
So if you're like me, you have vim configured to not save registers
in your viminfo file, so the answer is "there is no file to edit".

Or maybe your configuration does write them.

> For future generations reading this.... vim writes back to
> ~/.viminfo when you run the :wq! command. So you need to edit
> viminfo in vi mode or another editor, otherwise it just overwrites
> your edits.

By default, this is stored in ~/.viminfo but as also mentioned, this
filename can be changed. So if you want to store your viminfo in
~/cthulu/is/my/copilot then the "n" parameter of 'viminfo' or setting
'viminfofile' will change that location.

By giving you this information and the further details in the
help-files, it arms you with the information you need regardless of
your configuration.

> also qf in a command starts a new macro @F
> where as qF just appends to the existing macro.

Again, this goes back to the understanding that macros are stored in
registers. As mentioned in

:help quote_alpha

using an uppercase register name (when yanking, deleting, or
recording a macro), it appends to the existing contents.

> It says this in the docs, but the language is not clear.

:help q

"""
q{0-9a-zA-Z"} Record typed characters into register
{0-9a-zA-Z"} (uppercase to append).
""

If you have suggestions for improving the text, it's possible they
could be included. But it seems pretty clear that using the
uppercase version appends to that register.

-tim


--
--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/20210528113405.7a827584%40bigbox.attlocal.net.

No comments: