Search code examples
vim

What does @/="" do in Vim?


The symbol / is forward research, so I guess it means: what is stored is the forward research (i.e. /) register (@) needs to be replaced (=) by the empty string (""). Is it correct?

Any other registers like this one?


Solution

  • On its own, @/="" means nothing.

    If you prepend it with :help :let:

    :let @/=""
    

    then it means "set the @/ register to an empty string", which is a way of emptying it.

    You can do that with any writable register. See :help registers to figure out which ones are writable and which ones are read-only.

    Example uses:

    " put the name of the current file in the system clipboard
    :let @+ = @%
    " put the last Ex command in the system clipboard
    :let @+ = @:
    " put the last Ex command in register a for later use
    :let @a = @:
    

    Note that this is a quick and dirty method. :help setreg() is much cleaner but it is too verbose for casual use.