Install new cursors for Ubuntu  • • •  使用 AutoSSH       all posts in Archive

Registers in Vim

When using Vim and GVim, it's really disturbing that the copied text with Ctrl+C can't be pasted into Vim with "p" . What's the XXX hell happened?

This command is able to show the details in registers:

:reg

you'll see following similar output , it list the information stored in all registers :

--- Registers ---
""   the default register
"0   ^J
"1   h^J^J^Jdebttptutneraraverick
"2   h^J^J^Jdebttptutnerar
"3   h^J^J^Jdebttptutner
"4   h^J^J^Jdebttptu
"5   h^J^J^Jdebttp
"6   ^J^J^Jdeb
"7   n^Jdebttptutneraraverick
"8   using the eighth register
"9   n^Jdebttptutnerar
"-   m
"*   INFO] Total time: 38 seconds
"+   INFO] Total time: 38 seconds
":   reg
"%   test.test
"/   centralAuthenticationService

When we just yank with ' y ' in Vim, it will be copied to the "" register, so when put with 'p', will print "the default register"

But you can also yank with '  y"8 ' , and put with '  "8p '. Then it'll print "using the eighth register"

When we using Ctrl+C , the text will be copied to the system register '  "+ ' , so we have to put with ' "+p '
If you are in edit mode , you can use Shfit+Insert to copy the content in system register.