2

Ok I must have missed something vital here. Can someone please tell me what the difference between using "a and @a is? All I know is that @ is used together with let and e.g. echo and ” is used when pasting. However I find no sources that explains the difference and what the prefix mean.

3

Note: all of the following information (and much more) can be found using :help @, :help ", and :help let-@.

  • "ap,"ad, &c.: use register a in a put from or delete to.

  • @a: replay the contents of register a as a sequence of normal commands

  • :let @a = 'string': assign a string to register a.

Now, there is likely some confusion because @ and " are occasionally interchangeable:

  • ""p, "@p, p: put from register ", this is called the "unnamed register," but in fact it has at least two names, " and @.

  • @": replay the contents of register " as a normal command (this is rarely done).

  • @@: replay the previously used @{reg}.

Then, there are the let and expression usages:

  • :let @" = 'string': let @@ = 'string': assign a string to register ".

  • :echo @@, :echo @": echo the value of register "

  • :echo @: also echo the value of register ".

  • :echo "@, :echo ": syntax error.

Finally, you can execute registers as an ex command (i.e., cmdline mode),

  • :@a: execute contents of register a as an ex command.

  • :@:: execute the previous command line

  • :@@: execute the previous :@{reg}.

  • 1
    You might add :@a : apply the contents of register a as Ex command(s). – B Layer Jun 2 '18 at 0:47
  • @BLayer Good point, although I can't remember the last time I needed to use them – Mass Jun 2 '18 at 1:43
  • Cool. I actually use it quite a bit. For instance, I might be doing some quick hacking on a function or mapping...make a change, yank it (yap or yy or whatever) and load/reload with :@0. – B Layer Jun 2 '18 at 4:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.