We were unable to load Disqus. If you are a moderator please see our troubleshooting guide.
Nice article!
I am a Vim user from more than a decade but it seems that I've only scraped the surface about registers until now... Thank you, your article actually improved my quality of life by some degrees!
Thanks very much for this elucidation
Thanks Brian for the helpful post. Registers are quite abstract but your explanations are easy to grab.
Thank you for such a great article.!
Great article thanks :) Actually I ended up here, because I was wondering what is "- register. Is it treated as regular named register or has special meaning?
A relevant topic which was not took in account is the clipboard access that can be given upon compilation. I found this information in the vim.fandom
A short quote is bellow:
Assuming Vim was compiled with clipboard access, it is possible to access the "+ or "* registers, which can modify the system clipboard. In this case, one can copy with e.g. "+y in visual mode, or "+y{motion} in normal mode, and paste with e.g. "+p.
If your installation of Vim was not compiled with clipboard support, you must either install a package that has clipboard support, or use an external command such as xclip as an intermediary. See Accessing the system clipboard for detailed information.
ty
Absolutely great! I immediately wondered what the [s]ubstitue command was and found that it is what I've been looking for for a looong time.Thanks.
Mind blowing after knowing this! Thank you!
Awesome post!
Maybe another worth mentioning read-only register is "- (minus sign), which keeps the last deleted content.
Great post but I am bit confused, at first # is the "alternate file" register, then a few lines down its described as a search register. Which one is it?
Actually, what he mean is, if you initiate a search with any of these characters (/, ?, *, #), the search content will be stored in "/ register. (Not in the character you used for initiating the search)
Hi, Michael. `"#` is a register referencing the alternate file. `#` is a vim command to search for the work under the cursor. So if you use `#` to search for a word, you can later use the search register `"/` to reference that word.
hey, i had observed that when i try to delete lines in vim editor, using 'dd' command, there are getting stored in 1 to 9 register's with latest to oldest respectively. but, when i try to delete words using 'dw' command, those words are not getting stored in those registers!!!.
I want to store those deleted words(not lines) in the registers and reuse them later. can you tell me how to do this or suggest me some other way.
The documentation says: "Numbered register 1 contains the text deleted by the most recent delete or change command, unless the command specified another register or the text is less than one line (the small delete register is used then)."
So you have two options: use the small delete register, "-, or delete to a named register, for example, "adw .
Curiously, if you delete a word to a named register, it is _also_ stored in "0 ! But if you delete a line to a named register, it's not stored in "0 . This is based on my testing with vim 7.4.
whooa, nice post brian, thank you.
Thanks a mil, I am using this with JS Bin not it a shell and works great.
FYI, the "# register is writable, perhaps that changed recently, and is documented separately from the 3 remaining read-only registers
thanks.
this help me a lot. thanks.
Lately I have got myself doing a lot of :let @+ = @: in order to copy the last command to the clipboard and when I have a nice command online, simply copy and :@+<enter> In insert mode I am used to do a lot of Ctrl-r + to paste the clipboard content.
Not mentioned the quotestar register ("*)?
Why do you need @ in this: :let @+=@% ?
:%y+ allows you to copy the current file to the clipboard
Great post! not many comprehensive tutorials for us vim noobs out there.
Note that the numbered registers do not contain 'small deletes' (unless specifically designated in the delete command) which are deletes smaller than 1 line. Normally, the last 'small delete' is kept in the "- (small delete) register.
Great post! I'm still spinning up on Vim and came across this while trying to paste to the clipboard, using cygwin in windows so it's * instead of +. The only thing that took me a minute to realize was the different between referencing registers with " and @, but it eventually sank in while playing around with it.
This is the best VIM register overview I've come across for sure.
Really nice post. I've been using Vim for code editing for several years now. One thing that has been helpful is taking it slow. I don't try to learn many things about it, but integrate the few of them that I use every day to the point it becomes second nature. After a while, I see that I repeat some process over and over and look online how to simplify it with Vim and then learn to do just that until it becomes second nature.
Your post helped me with that today. Thank you!
Really useful post, and certainly registers are an overlooked part of using Vim.
This is a very nice and concise post. Registers have always been those things that I kind of understand... Nice to see it all written down here.
Hi Brian, thank for your post. it is very useful and easy to understand the vim registers idea.
keep your working.
this is exactly the article i needed. thank you!