Skip to main content
Share Your Experience: Take the 2024 Developer Survey

Questions tagged [register]

Registers store snippets of text for yank (copy), delete (cut), put (paste). In Vim, registers are also used for macro playback and some registers are special and can reference the OS clipboard or evaluate expressions.

Filter by
Sorted by
Tagged with
0 votes
0 answers
19 views

WSL: Value of v:event.regname for non-alpha-numeric registers

I have a rather slow autocmd TextYankPost command that I'm trying to limit to the quoteplus (+) register. I've tried the following to get this to work: autocmd TextYankPost * if v:event.regname is '+' ...
Rob Mosher's user avatar
1 vote
4 answers
37 views

Rotate list of lines

Assume you have the following block of text (yes: I am using vim-latex, but this is not relevant): \begin{itemize} \item 1 % [[[ \item 2 \item 3 \item 4 \item 5 % ]]] \item 6 \end{itemize} My ...
brad's user avatar
  • 131
0 votes
1 answer
24 views

Vim register becomes random values in gvim

Given the php code at the end, I add it to my gVim register with "ky. Everything is fine. After some time, when I use it, the vim register looks like this: jjjjjjjjjjjjj/^...
Vinn's user avatar
  • 781
0 votes
0 answers
40 views

First attempt to paste from a register requires pause after <C-R>

When I yank text into any register, the first attempt to paste the content in insert mode using <C-R> doesn't do anything if I follow it too quickly with the name of the register. It works fine ...
user2153235's user avatar
0 votes
0 answers
50 views

Behavior of copy/paste with system register + has suddenly changed

(Vim version and system info follows at bottom) Never had any problems copying to the system register with "+y before, nor pasting from that register into another application or into a terminal. ...
Newlin's user avatar
  • 11
2 votes
1 answer
215 views

Neovim paste without overwriting register w/ Lua

So I know with vimscript you could make paste not overwrite your register with this: vnoremap p pgvy And I've tried a few ways to get this to with with Lua such as: vim.api.nvim_set_keymap('n', 'p', '...
Zach B.'s user avatar
  • 123
0 votes
1 answer
68 views

Change the clipboard register's name

To use Neovim with my system clipboard I have to use the + register which I find inconvenient. When I type something like "+p I have to bounce my pinky all around. Is there a way to change the ...
fin444's user avatar
  • 103
1 vote
1 answer
54 views

Search for ^@ in register '+'

After yanking into register + from Visual Block mode, the lines break are marked with ^@. I would like to detect this character, but I can't.. For example, if register + contains ^@ as shown below ...
xyx's user avatar
  • 464
1 vote
1 answer
111 views

Syncing x clipboard with yanks and put only?

I have discovered the joy of having :set clipboard^=unnamedplus. One issue I often face however is having whatever was last copied or yanked be overwritten by what I just deleted. I don't think ...
dvqc's user avatar
  • 13
0 votes
2 answers
111 views

How can copy the matched string into register +?

For the below data: -150000 2023-03-30 421.67 2023-04-20 575 2023-05-20 I can substitute the whole line with the first string :%s/\v.{-1,}\s+(.+)/\1 Then the content was changed into: -...
showkey's user avatar
  • 1,140
1 vote
1 answer
158 views

Remap p if no register is specified

To stop pasting over a selection from yanking that selection, I would like to remap p so that it doesn't yank the just-rewritten selection: vim.keymap.set("x", "p", [["_dP]]) ...
minseong's user avatar
  • 2,333
3 votes
1 answer
445 views

How to clear the uppercase registers?

The uppercase register has this nice characteristic of allowing appends to them. However, every time I use them to yank a series of text, when it's time to paste them, I can see the old text from when ...
Guilherme Marthe's user avatar
1 vote
2 answers
42 views

Why my visual selection buffer contains ^@

I am writing a function to reformat a visual selection: function! FormatText() range " Calling this function has ended visual mode, so it must be started " again before the selection can ...
Konstantin Glukhov's user avatar
1 vote
2 answers
238 views

Yank non-consecutive lines into the register?

I'm surprised this hasn't been asked yet, but how do I copy non-consecutive lines into the buffer at once? For example, let's say my file looks like this: 1 2 3 4 5 6 7 8 9 10 What commands can I use ...
qotsa42's user avatar
  • 21
0 votes
2 answers
50 views

Report more than 200 lines cut/pasted -- Vividly?

I have a text document where I frequently move/cut large blocks of text. Every 2-3 months I inadvertently cut or paste a huge number of lines (60,000 today) and discover the error hours, or even days, ...
cesces's user avatar
  • 25
0 votes
1 answer
211 views

Expression Register - Power, Root & Mod

Foreword In case you don't know, you can evaluate math expressions in vim/neovim with this command: While in INSERT mode, press CTRL+R, then =. Example: =2+2 inserts 4 into your buffer. Question Is ...
Bog's user avatar
  • 479
0 votes
1 answer
23 views

Replace with fixed character (e.g. spaces) and add replaced text to register

I would like to have a selection that whose contents I replace with a command like r, but the replaced text is added to a register. The use case is editing a Markdown table in Vim, where I want to ...
prolyx's user avatar
  • 143
0 votes
4 answers
209 views

Replace every character on a visual selection with a register's character

I'll try to illustrate as clear as I can. Suppose I have the following text open in vim/nvim _________ | | | 9999 | | | --------- If select 9999 visually and then hit r8, this ...
Diwas10's user avatar
  • 115
3 votes
1 answer
74 views

What does ^= mean in set command?

I had seen a set command in .vimrc: set clipboard^=unnamed,unnamedplus What does ^= mean in set command?What is the difference between set clipboard^=unnamed,unnamedplus and set clipboard=unnamed,...
newview's user avatar
  • 301
0 votes
2 answers
46 views

Copy text from all folds, excluding titles

How do I copy all lines from all folds, excluding the fold titles?
markling's user avatar
  • 389
1 vote
1 answer
29 views

Is there any easy way to undo put if I selected the wrong register?

Sometimes I accidently put from the wrong register and end up hitting u to undo, but then I have to reselect the text that I was trying to replace. Is there an easy way to either reapply the put from ...
Henry Crans's user avatar
0 votes
1 answer
142 views

Yank list of lines into a register in vimscript

I am writing a function and I wish to yank a range of lines into a register. The line that I cannot fix is the following: let @" = getline(l:line_in,l:line_out) where l:line_in and l:line out ...
Barzi2001's user avatar
  • 606
2 votes
1 answer
45 views

How do the * and + registrers behave in the virtual console?

My Vim is installed with +clipboard support, and all works just fine. I know that the clipboard comes with X, so there isn't such a thing in a virtual console (or, at least, this is what I've ...
Enlico's user avatar
  • 2,214
1 vote
1 answer
44 views

How does recording a macro differ from defining a macro directly?

In my Vim configuration, I have mapped the <C-j> key to <cmd>bn<CR>, but because the C-j key corresponds to the null character in Vim, this causes some strange issues when defining ...
Andy Wang's user avatar
0 votes
1 answer
52 views

Paste register contents from :reg screen

:reg displays the contents of the numbered and special registers. Is there a way to then paste a register but retain the output of :reg on the screen? This avoids the need to store the register name ...
Trent Gm's user avatar
  • 103
2 votes
2 answers
90 views

Is there a plugin for saving/loading registers' contents to/from files in a convenient way?

tl;dr Is there a Vim plugin that allows me to save/load registers to/from files with minimal typing, preview of registers, and other amenities? Long version Vim has a lot of registers. However, the &...
Enlico's user avatar
  • 2,214
7 votes
3 answers
1k views

How do I search the contents of registers?

I have a bad habit of deleting some text a, heading off to another section of the document to paste it, and finding something else along the way that I need to delete. When I get to my final ...
LSpice's user avatar
  • 259
3 votes
0 answers
139 views

Store the current filename in a given register

When I exchange with colleagues about the code, when I refer to given functions, I like to also mention the file. Since this exchange does not usually take place within vim, I usually copy them out ...
clem steredenn's user avatar
0 votes
0 answers
617 views

(Code review) Copying file path relative to cwd with the line number appended

I am replicating what PHPStorm and VSCode do by allowing me to copy the file path and line number (plus column) to clipboard. I have written a function in lua to do this, but, I wanted to ask about ...
Marwan Fikrat's user avatar
3 votes
1 answer
181 views

How to save a macro (for quickly printing a variable)?

I'm trying to create a macro for an action that I very frequently use in Python: printing a variable in a bright color so it can easily be found in the traces while debugging. So lets say there's ...
Opifex's user avatar
  • 227
3 votes
1 answer
179 views

Inserting the content of a register where a macro is recorded results in control characters becoming unicode characters

If I hit Ctrl+V and then Escape while in insert or ex mode, I get ^[ as a single character. If I hit qqEscapeq and then go see :registers, I see that q contains ^[<80><fd>a, which are ...
Enlico's user avatar
  • 2,214
4 votes
1 answer
325 views

How to reference a register in an ex command

I'm trying to write what I thought would be a simple macro to take some values that have been yanked into some registers (a & b) and use bc to do some addition with those values. Here is the ...
cewood's user avatar
  • 143
3 votes
1 answer
345 views

Execute Ex command inside expression register

Executing :echo 'hello' prints "hello". Executing "=echo 'hello'<cr>p however, results in multiple errors. Is there a way to execute Ex commands inside of the expression register?
Luiz Martins's user avatar
0 votes
2 answers
73 views

How to execute a shell script from a line in a file with `%` in it

I have a shell script on a line alone in a file which I would like to be able to easily execute from vim. Normally I could simply use Y:!^R", but this particular script has % in it, which is ...
Iiridayn's user avatar
  • 193
5 votes
1 answer
203 views

Register for your last action (.)

Vim has a lot of useful registers from which you can access the contents of various actions. There's ": for the last command in the command line, "/ for the last search, ". for the last ...
Luiz Martins's user avatar
0 votes
0 answers
43 views

How do I show the jumps list permanently in a window?

As the title says, is there a way to view the jumps list opened in a permanent window? The question is also valid for registers list.
user515933's user avatar
3 votes
2 answers
171 views

Manipulate the dot command without editing text in insert mode

I need to manipulate the dot command without directly editing the buffer for a plugin I'm developing. The plugin needs to manually append text to the dot command that will be executed while in insert ...
tversteeg's user avatar
  • 165
4 votes
1 answer
432 views

Escape key adds extra bytes into the register when recording a macro [duplicate]

When I try to record a macro that involves hitting Esc the following bytes are added to the register <80><fd>a for example if I type qq<Esc>q when I :echo @q I get back ^[<80>&...
Kasper-34's user avatar
0 votes
1 answer
62 views

Why does cw followed by ctrl-r register consist of two edits?

I did cwCtrl-Ra at the beginning of a word to paste the content of register a in its place. And this, I thought, is done entering insert mode only once; or at least, never going back to normal mode. ...
Enlico's user avatar
  • 2,214
0 votes
1 answer
280 views

What's the easiest way to replace some text with the contents of the clipboard when using clipboard=unnamed?

Assume I've copied some text into the clipboard from another program. I'm on MacOS, so in Vim terms, this means the text is in the + and * registers (I have verified this using :registers). I use ...
Andrew Ferrier's user avatar
0 votes
1 answer
122 views

When searching and replacing can I store a capture group to a register?

This is similar but I am unable to draw the information I need from it: How to store all occurrences of a multiline search in a register? I have these lines ################### trim 8 ...
Kes's user avatar
  • 663
0 votes
2 answers
160 views

Yanking range into register while ignoring blank lines

I’m trying to yank a range into a register while ignoring blank lines. My range is from line 10 to the end of the file. :10,$v/./"*y Looking at my registers in :reg I see that my text is not in ...
BrianWilson's user avatar
0 votes
2 answers
140 views

Can a register's value be checked at startup?

There are probably 20 better ways to do what I'm trying to do. Please direct me to them if so - I haven't found them and not quite sure what to terms to search. I would prefer to set background=dark ...
user avatar
4 votes
2 answers
445 views

Is there any way of copying a macro inside a register to a different register?

I've discovered I can execute vim macros from the command line using the following command: vim myfile -c "argdo norm @aZZ" This command executed from the command line will execute a macro ...
raylight's user avatar
  • 535
0 votes
1 answer
50 views

Is it possible to call a shell command which includes default register contents inside a function?

I want to write a function which opens a vim plugin's Github page, eg calling the function while on this line: Plug 'tpope/vim-rhubarb' ... will do !open https://github.com/tpope/vim-rhubarb. Here's ...
Zubin's user avatar
  • 101
0 votes
2 answers
33 views

search and replace block to a line

I would like to replace a multiline block to one line for example : if (... ){ //comment0 line1 line2 } some code if (... ){ //comment0 line1 line2 } ...
Dor marcus's user avatar
1 vote
2 answers
108 views

search last substitution

After doing :%s/foo/bar/g I can type :<C-r>/ to place foo into the command line. How can I place bar into the command line? I ultimately want to do a series of: :%s/foo/bar/g :%s/bar/baz/g :%s/...
minseong's user avatar
  • 2,333
0 votes
1 answer
44 views

Yanking into register within a script is not working

Given a file like this: Roy Maurice Jen Douglas If I were to type the following commands: ggVj"zy, followed by :reg z, I would see Roy and Maurice. Now I want to yank Jen and Douglas into the z ...
Phil R's user avatar
  • 503
1 vote
0 answers
26 views

How to point the cursor to result when search by 'let @/ = '?

To reproduce this problem: Open a new vim window, input "abc", leave cursor at the end of line set hlsearch let @/ = "abc" The cursor doesn't point to the beginning of "abc&...
aj3423's user avatar
  • 199
0 votes
1 answer
472 views

Delete/yank into multiple registers at the same time?

Is there a way to have y/d/c/x/s output into multiple registers at the same time - for example, "a as well as the system clipboard "+? I can do "aY"+Y obviously, and with Y it's ...
pxeger's user avatar
  • 111