Where are vim macros stored

109 views
Skip to first unread message

Ruben Safir

unread,
May 28, 2021, 9:45:11 AM5/28/21
to v...@vim.org
Where are the vim macros stored. I want to edit them by hand
--
So many immigrant groups have swept through our town
that Brooklyn, like Atlantis, reaches mythological
proportions in the mind of the world - RI Safir 1998
http://www.mrbrklyn.com

DRM is THEFT - We are the STAKEHOLDERS - RI Safir 2002
http://www.nylxs.com - Leadership Development in Free Software
http://www2.mrbrklyn.com/resources - Unpublished Archive
http://www.coinhangout.com - coins!
http://www.brooklyn-living.com

Being so tracked is for FARM ANIMALS and and extermination camps,
but incompatible with living as a free human being. -RI Safir 2013

Christian Brabandt

unread,
May 28, 2021, 10:03:11 AM5/28/21
to v...@vim.org

On Fr, 28 Mai 2021, Ruben Safir wrote:

> Where are the vim macros stored. I want to edit them by hand

in the register you specified.

Best,
Christian
--
Beispiele, wie sich die Menschen über das Unerwartete, ja
Unerträgliche durch poetische Formen begütigen:
empirisch erscheinende absolute Gewalt
Oberon, Blaubart.
-- Goethe, Maximen und Reflektionen, Nr. 1311

Ruben Safir

unread,
May 28, 2021, 10:07:16 AM5/28/21
to vim...@googlegroups.com
On 5/28/21 10:02 AM, Christian Brabandt wrote:
>> Where are the vim macros stored. I want to edit them by hand
> in the register you specified.
>
> Best,
> Christian

that is not the answer to the question I asked.

Where are they STORED. Not how do I access them.

Where on the filesystem are they stored.

Tim Chase

unread,
May 28, 2021, 10:21:28 AM5/28/21
to vim...@googlegroups.com
On 2021-05-28 10:05, Ruben Safir wrote:
> On 5/28/21 10:02 AM, Christian Brabandt wrote:
> >> Where are the vim macros stored. I want to edit them by hand
> > in the register you specified.
>
> that is not the answer to the question I asked.
>
> Where are they STORED. Not how do I access them.
>
> Where on the filesystem are they stored.

Christian answered your question: vim stores macros in *registers*.

However, vim optionally stores registers based on your 'viminfo'
setting: either in your ~/.viminfo (or in a different file if you
used the "n" option) or not at all. See

:help viminfo-<
:help viminfo-n
:help viminfo-file

-tim



Ruben Safir

unread,
May 28, 2021, 10:31:04 AM5/28/21
to vim...@googlegroups.com
On 5/28/21 10:21 AM, Tim Chase wrote:
> On 2021-05-28 10:05, Ruben Safir wrote:
>> On 5/28/21 10:02 AM, Christian Brabandt wrote:
>>>> Where are the vim macros stored. I want to edit them by hand
>>> in the register you specified.
>>
>> that is not the answer to the question I asked.
>>
>> Where are they STORED. Not how do I access them.
>>
>> Where on the filesystem are they stored.
>
> Christian answered your question: vim stores macros in *registers*.

Which is where?

./.viminfo has command line history in it. The macros are stored in there?

>
> However, vim optionally stores registers based on your 'viminfo'
> setting: either in your ~/.viminfo (or in a different file if you
> used the "n" option) or not at all. See
>
> :help viminfo-<
> :help viminfo-n
> :help viminfo-file
>
> -tim
>
>
>


Christian Brabandt

unread,
May 28, 2021, 10:36:21 AM5/28/21
to vim...@googlegroups.com

On Fr, 28 Mai 2021, Ruben Safir wrote:

> On 5/28/21 10:21 AM, Tim Chase wrote:
> > On 2021-05-28 10:05, Ruben Safir wrote:
> >> On 5/28/21 10:02 AM, Christian Brabandt wrote:
> >>>> Where are the vim macros stored. I want to edit them by hand
> >>> in the register you specified.
> >>
> >> that is not the answer to the question I asked.
> >>
> >> Where are they STORED. Not how do I access them.
> >>
> >> Where on the filesystem are they stored.
> >
> > Christian answered your question: vim stores macros in *registers*.
>
> Which is where?

In memory. You can edit them by e.g. pasting them into a buffer,
changing them and them yanking them again into a register.

> ./.viminfo has command line history in it. The macros are stored in
> there?

Yes I think they can.

Best,
Christian
--
Kein Enthusiasmus der Liebe ist so groß als der der Zusammengewöhnung,
der auf jenen folgt.
-- Jean Paul

Karthick Gururaj

unread,
May 28, 2021, 10:48:17 AM5/28/21
to vim_use
On Fri, May 28, 2021 at 8:01 PM Ruben Safir <ruben...@my.liu.edu> wrote:
>
> On 5/28/21 10:21 AM, Tim Chase wrote:
> > On 2021-05-28 10:05, Ruben Safir wrote:
> >> On 5/28/21 10:02 AM, Christian Brabandt wrote:
> >>>> Where are the vim macros stored. I want to edit them by hand
> >>> in the register you specified.
> >>
> >> that is not the answer to the question I asked.
> >>
> >> Where are they STORED. Not how do I access them.
> >>
> >> Where on the filesystem are they stored.
> >
> > Christian answered your question: vim stores macros in *registers*.
>
> Which is where?
>
> ./.viminfo has command line history in it. The macros are stored in there?


I'm mostly an observer here - but..
A. You should know you got a useful and correct response to your question
B. If that is not the answer you are looking for, you should go back
and check the question you asked.
C. Entirely optional - but politeness goes a long way.

You can "edit" the contents of the registers in many ways. You can
even set the register directly with a :let
:let @a="D"
You can view it with an :echo @a

However - if you are using registers for recording macros - the
register may not have printable characters.

Ruben Safir

unread,
May 28, 2021, 11:11:57 AM5/28/21
to vim...@googlegroups.com
On 5/28/21 10:47 AM, Karthick Gururaj wrote:
> I'm mostly an observer here - but..
> A. You should know you got a useful and correct response to your question
> B. If that is not the answer you are looking for, you should go back
> and check the question you asked.
> C. Entirely optional - but politeness goes a long way.
>
> You can "edit" the contents of the registers in many ways. You can
> even set the register directly with a :let
> :let @a="D"
> You can view it with an :echo @a
>
> However - if you are using registers for recording macros - the
> register may not have printable characters.

I just want to open the file and edit it. I don't want to go through
the manturations of vim, which is why I asked where they are stored.

You are right that politeness goes a long way, and so does the
politeness that requires short communication that is the point which is
exactly what I did.

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. They don't generate from the eether, so
they need to come from some file. I used to handle these things with
.vim, files or directly with vimrc in vim scripting language.

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.

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

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

Thanks for the help

Reuvain

Tim Chase

unread,
May 28, 2021, 12:34:12 PM5/28/21
to Ruben Safir, vim...@googlegroups.com
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


Ruben Safir

unread,
May 28, 2021, 1:32:42 PM5/28/21
to Tim Chase, vim...@googlegroups.com
On 5/28/21 12:34 PM, Tim Chase wrote:
> 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.


thank you!

Grant Taylor

unread,
May 28, 2021, 1:47:27 PM5/28/21
to vim...@googlegroups.com
On 5/28/21 7:43 AM, Ruben Safir wrote:
> Where are the vim macros stored. I want to edit them by hand

My understanding is that, by default, macros only exist in memory, are
volatile, and not stored persistently. The only live in vim's memory
while vim is running.

There are some non-default options that you can use to change some of that.



--
Grant. . . .
unix || die

Tim Chase

unread,
May 28, 2021, 2:10:36 PM5/28/21
to 'Grant Taylor' via vim_use
On 2021-05-28 11:47, 'Grant Taylor' via vim_use wrote:
> My understanding is that, by default, macros only exist in memory,
> are volatile, and not stored persistently. The only live in vim's
> memory while vim is running.
>
> There are some non-default options that you can use to change some
> of that.

Depends on whether vim was started in compatible mode or not. The
gritty details of "should I default to compatible or not" is spelled
out at

:help compatible-default

In compatible mode, it doesn't store registers in your viminfo,
whereas for nocp mode, it does by default:

:help 'viminfo'
Vi default: ""
Vim default
for MS-Windows: '100,<50,s10,h,rA:,rB:,
for Amiga: '100,<50,s10,h,rdf0:,rdf1:,rdf2:
for others: '100,<50,s10,h)

So based on a number of factors (initial 'cp' determination,
overridden 'cp' setting, manually setting 'viminfo', manually setting
'viminfofile', etc), the results may vary. Tuneable to the point of
fault^Wconfusion. ;-)

-tim


Reply all
Reply to author
Forward
0 new messages