Questions tagged [vim-registers]
35 questions
498
votes
29 answers
In Vim is there a way to delete without putting text in the register?
Using Vim I often want to replace a block of code with a block that I just yanked.
But when I delete the block of code that is to be replaced, that block itself goes into the register which erases the block I just yanked. So I've got in the habit of…
![](../../users/profiles/4639.webp)
Edward Tanguay
- 176,854
- 291
- 683
- 1,015
94
votes
2 answers
Copy from one register to another
How to copy the contents of one register to another without pasting on clipboard? I'd yanked one text and it got yanked in the default " register. Now I want to copy another text without deleting/overwriting " register. So I want to move the…
![](../../users/profiles/182296.webp)
bluegenetic
- 1,109
- 3
- 10
- 13
62
votes
7 answers
How to clear vim registers effectively?
Registers in vim are a great feature to store text snippets and even to run commands on the text stored within them. However, I'm a tidy person and tend to clean things up when I'm done.
I know that if I wanted to clear register a, I can use qaq.
I…
![](../../users/profiles/1378331.webp)
Robin Klose
- 725
- 1
- 5
- 7
11
votes
2 answers
Vim Register Use in Ex Mode
Potentially 2 questions in one. I would like to know how to reference a register in Ex mode.
For instance, I'm editing a file and I want to save the file with a timestamp (or just datestamp really) appended to it.
I know I can set register to the…
![](../../users/profiles/286531.webp)
Peck
- 782
- 1
- 7
- 26
9
votes
2 answers
Combining registers in vim
Is it possible to combine registers in vim? For example, if I have registers "a, "b, "c, can I easily create register "d which is a concatenation of all three? That is, without pasting them all and then selecting the whole thing.
![](../../users/profiles/22724.webp)
Marcin
- 11,616
- 9
- 39
- 47
8
votes
4 answers
Vim - capture in between slashes?
Is there a motion for capturing text in between / or \? I know there is motions for other symbols ---
ci" - Capture 'text' inside "text"
vi( - Visual capture int var inside foo(int var)
di[ - Delete word [word] into []
The only workaround I can find…
![](../../users/profiles/1042350.webp)
dook
- 973
- 1
- 10
- 26
6
votes
2 answers
What is the difference between buffers and registers in vim?
In vim, command :reg[ister] shows me the list of registers while :ls shows the list of buffers but I'm not sure what the exact difference between registers and buffers is. I think that registers are virtual memory and are used with "(double…
![](../../users/profiles/2131344.webp)
StarMomo
- 105
- 1
- 7
5
votes
3 answers
In vim, how can I add a carriage return to a register using setreg?
I have this command in my .vimrc:
vip:normal @g
When I set the register 'g' by typing in the buffer, like this, it works:
qgjq
If I type :registers, it shows:
--- Registers ---
"g ^Mj
After that, typing @g results in a carriage return…
![](../../users/profiles/226931.webp)
renick
- 667
- 1
- 6
- 16
4
votes
4 answers
remove newlines from a register in vim?
I have a long list of different names of universities. I'm trying to build a synonym table by collating lines with certain unique keywords; that is, in the file, I'll identify that Harvard is the keyword here:
Harvard Business School|
Harvard…
![](../../users/profiles/78202.webp)
Myer
- 3,434
- 1
- 34
- 46
3
votes
1 answer
How to copy from Vim to system clipboard using wayland and without compiled vim `+clipboard` feature flag
I cannot copy into the + or * register.
:echo has('clipboard') from within Vim returns 0 meaning I don't have that feature flag, I don't want to recompile.
I'm running wayland so I cannot use X11 based solutions
![](../../users/profiles/8870594.webp)
brother-bilo
- 280
- 1
- 9
3
votes
3 answers
Write to two registers at the same time in Vim
I'm using:
set clipboard=unnamed
So that cut and copied selections go to the * register, which is conveniently linked to the x clipboard (I'm using Linux).
I would like to have it also in the + register to get both middle-mouse-pasting and…
![](../../users/profiles/627911.webp)
e-malito
- 767
- 1
- 5
- 14
2
votes
1 answer
Same registers for different VIM tabs
I'm trying to make a copy paste from 1 file I have opened in a tab to another file I have opened in another tab.
So I use the visual block to get my selection, yank it, but when I switch to other tab, it doesn't paste, it says:
Nothing to…
![](../../users/profiles/795733.webp)
JTL
- 21
- 1
2
votes
2 answers
Clear vim register, but still able to paste
I wanted to yank all matching lines of a buffer in a give register. I choose "A
:g//y A
did this trick for me.I guess
"Ap
is the command to paste A's content, I got my matching lines plus older lines as well, tried clearing A using
:let…
![](../../users/profiles/2636776.webp)
Logan
- 174
- 9
2
votes
2 answers
Vim registers standards
I was thinking of setting my registers to equal common coding techniques. For
example, I was thinking of doing this:
:let @i = "int i=0;"
Then I would set f for for loop, w for while loop etc. Is this a bad technique or is there a better way of…
![](../../users/profiles/1459075.webp)
Brandon Ling
- 3,480
- 6
- 28
- 46
1
vote
1 answer
Difference between @a="0" and @a=@0
I've the following text copied to the "0 register
test
test
If I want to copy the content of the "0 register to the "a register I do
:let @a=@0
Then, if I paste the content of "a register I obtain
test
test
Now, to paste the content of the "0…
![](../../users/profiles/11551787.webp)
user515933
- 11
- 2