How do I use vim registers?

后端 未结 17 2122
一向
一向 2020-11-27 08:58

I only know of one instance using registers is via CtrlR* whereby I paste text from a clipboard.

What are other uses of registers?

17条回答
  •  野性不改
    2020-11-27 09:28

    From vim's help page:

    CTRL-R {0-9a-z"%#:-=.}                  *c_CTRL-R* *c_*
            Insert the contents of a numbered or named register.  Between
            typing CTRL-R and the second character '"' will be displayed
            <...snip...>
            Special registers:
                '"' the unnamed register, containing the text of
                    the last delete or yank
                '%' the current file name
                '#' the alternate file name
                '*' the clipboard contents (X11: primary selection)
                '+' the clipboard contents
                '/' the last search pattern
                ':' the last command-line
                '-' the last small (less than a line) delete
                '.' the last inserted text
                                *c_CTRL-R_=*
                '=' the expression register: you are prompted to
                    enter an expression (see |expression|)
                    (doesn't work at the expression prompt; some
                    things such as changing the buffer or current
                    window are not allowed to avoid side effects)
                    When the result is a |List| the items are used
                    as lines.  They can have line breaks inside
                    too.
                    When the result is a Float it's automatically
                    converted to a String.
            See |registers| about registers.  {not in Vi}
            <...snip...>
    

提交回复
热议问题