initializing a named register at startup

16 views
Skip to first unread message

Ernie Rael

unread,
Jan 20, 2021, 10:20:59 AM1/20/21
to vim...@googlegroups.com
Hi all,

jVi had a feature request, something about supporting

   let @a= "some string"

which is supposed to initialized the named buffer at startup. Something
the user wanted to use with macros. I pointed out that jVi persists
named buffers between session and that satisfied his requirement. But, I
can see how a feature like this would be handy.

I can't find a description of the "@a=" behavior in vimhelp. A pointer
is appreciated.

-ernie

Thomas Köhler

unread,
Jan 20, 2021, 10:47:47 AM1/20/21
to Ernie Rael, vim...@googlegroups.com
Hi Ernie,
You can write this in your .vimrc and have the named register a
have initialized that way:

let @a = "some string"

see
:help :let-@
for the help on that.

> -ernie

Ciao,
Thomas

--
Thomas Köhler Email: jean...@picard.franken.de
<>< WWW: http://gott-gehabt.de
IRC: tkoehler Freenode: thkoehler
PGP public key available from Homepage!
signature.asc

Ernie Rael

unread,
Jan 22, 2021, 4:21:22 AM1/22/21
to vim...@vim.org
Hi all,

jVi had a feature request, something about supporting

let @a= "some string"

which is supposed to initialized the named buffer at startup. Something
the user wanted to use with macros. I pointed out that jVi persists
named buffers between session and that satisfied his requirement. But, I
can see how a feature this would be handy.

I can't find a description of the "@a=" behavior in vimhelp. A pointer
is appreciated.

-ernie

Tony Mechelynck

unread,
Jan 24, 2021, 10:15:04 PM1/24/21
to Ernie Rael, vim_dev
Possibility 1:
If the < or " item is not present in the 'viminfo' option then all
registers are saved on shutdown and restored at startup. If it is
present with value zero, then no registers are saved. If it is present
with a value >0 then at most that number of lines is saved for each
register.
See :help 'vi'

Possibility 2:
Most registers can be treated as string variables named @a, @b etc.
They can be read by including them in an expression. Most of them can
also be set by means of a :let statement. To do it at startup, put it
in your vimrc.
See:
:help :let-@
:help registers
:help expr-register

You can also put a register into your editfile, or delete or yank into
a register. I use the following mappings but of course they can also
be typed:
:map <F4> :$put +<CR>
:map <S-F4> :0put +<CR>
The above puts the clipboard linewise, after the last line for F4 or
before the first line for Shift-F4
See also:
:help y
:help d
:help p
:help P
:help :yank
:help :delete
:help :put

Best regards,
Tony.
Reply all
Reply to author
Forward
0 new messages