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
1
vote
1answer
40 views

How do I append to the unnamed register?

In particular, I'd like to append to the unnamed register with the :global command.
1
vote
1answer
48 views

How to clear a vim register (vi/ex buffer)?

In the ex linage of editors, one can append to a register(vim)/buffer(ex,vi) by specifying the register name in uppercase. As an example g/pat/y A will append every line match pat to register a. But ...
0
votes
1answer
17 views

no + or * register when entering vim from ranger

I'm running Ubuntu 18.04 with i3wm. Vim and vim-gtk3 packages are installed. If I'm in a regular terminal and I start editing a file in vim. I can yank text to the + register as expected. However, if ...
1
vote
1answer
14 views

Set up a register backed by a file to fill in for xterm clipboard on a server without a display?

I used to use "+y and "+p in vim for copy pasting across vim instances. This also has the advantage that you can use "+ as a register for any command you know, including deletions etc. Now that I'm ...
0
votes
1answer
48 views

How can I put the system clipboard into a vim register?

Basically the opposite of this question. This is on macOS. I copy from a program using ⌘C and I want to add that text to "" or "0 so when I cw or something similar I don't obliterate my copied text. ...
1
vote
2answers
37 views

Embed <Return> within register

I want to have predefined register that will jump to the location matched by regular expression, i.e. in vimrc I add: let @a="/=\"" That will be useful for me when I want to navigate to the next ...
0
votes
0answers
24 views

How to copy/paste from a local machine to a remote server

I am trying to copy text onto my clipboard on a local mac and paste it onto a remote linux server. I am able to yank the text from my local machine onto my machine's clipboard using: "*yy And I can ...
1
vote
1answer
28 views

Yank inside quotes of a range of lines to a register and separate them with a new line character

I would like to populate a register with the text inside quotes for a range of lines. The register should contain all yanked text separated with new line characters. Example lines: The "black" cat A "...
2
votes
1answer
78 views

Execute the contents of a register with a delay after each command

So far, I managed to implement a function that adds a delay after "putting" each character contained in a register to the screen: function! AnimateInsertion() abort " split contents of last ...
1
vote
1answer
26 views

How do I setup a command to use the “in word” as an argument

I would like to set up vim-fzf to do git grep/rg/ag/whatever on the word my cursor is over. With vim-grepper I was able to do gsiw for this and it was fantastic. With fzf I can't seem to figure out ...
1
vote
0answers
34 views

Preview previously yanked text before put

I know that previous yanks are kept in numbered yank registers, a preview available with :registers. However this requires to keep a mental model which yank went where, with these numbers ever ...
0
votes
1answer
61 views

How to convert register contents to something readable similar to :register command?

Let's assume there is a macro stored in register 'r' I can obtain the contents of this register by executing getreg('r'), but if I print this then it can often be unreadable. I noticed though that ...
2
votes
2answers
132 views

How not to let text in selection mode go to registers

I am using nvim-qt on Windows and I have set up the clipboard option: set clipboard=unnamedplus I found that text in Select mode will go to the +, * and " register after I start to type the ...
2
votes
1answer
50 views

How do you read the contents of a macro into your buffer?

I know that you can use let @x = @w to copy the contents of a macro from one register to another, but how do you read the contents of your macro register into the buffer?
2
votes
1answer
54 views

Why do I lose what I copied with "+y after exiting vim, and how to change that? [duplicate]

The + register always worked weird for me but only now I noticed a regularity in the weirdness: after I quit vim I can't paste anymore, it's as if the clipboard was replaced with a blank. Why, and can ...
3
votes
1answer
101 views

running external command on contents of register

I know I can use ranges/marks with the ! command like so: %! column -t etc. Is there any way to pass a register to the external command instead of the current buffer? I imagine it would look ...
2
votes
1answer
63 views

How does p really works as related to content put in registers?

I've read this question and answer already, however it could not solve my doubts. As far as my understanding is correct, p always has the same effect (putting the content of a register, by default ...
4
votes
4answers
342 views

How to apply a register to a command?

I have the given file 4 apples 2 bananas 6 peaches 3 grapes 1 pineapple 5 pears 3 tomatoes What I want to do is to recieve the following result instead: apple apple apple apple banana banana peach ...
2
votes
1answer
33 views

Pasting modified register contents into Visual Block selection

Consider this mapping: vnoremap <leader>U ygv"=toupper(@@)<cr>p It will yank the current visual selection, select it back, and then put a modified version of it. In this case, uppercase ...
3
votes
2answers
195 views

Using visual selection or register for search and replace

Is there a way to use a register or visual selection for search and replace? I have some longer sequence of words that are used repeatedly in my script. I want to replace them all but want to avoid ...
2
votes
1answer
184 views

unable to copy to system clipboard with +clipboard and +xterm_clipboard in vimx

The system is Centos7.2. I have installed vim-enhanced and vim-X11, used vimx command. It shows that vimx supports clipboard and xterm_clipboard. But in vimx, there is no reg + and reg *. I can't ...
1
vote
1answer
46 views

Yank both sides of equation

While writing in latex I often want to copy a math equation's right hand side or left hand side. For example I have something like this \begin{gather*} 5 \cdot \left( A A 3 \right) + 50 \cdot \...
2
votes
1answer
40 views

Is it possible to run a script on a register content and send its output to another register on Vim?

Let's consider that I have the following bash script called time.bash: #!/bin/bash date -d @$1 This script converts the epoch timestamp to its corresponding date as the following: $ ./time.bash ...
3
votes
1answer
102 views

How to use register in a script without side effect?

I want to create a function like this: function Foo() copy something from buffer into a register do something restore register endfunction Foo must have no side effect, every register ...
4
votes
1answer
171 views

Vi: * and + registers do not exist

I'm unable to use the system clipboard in Vim. I'm using ssh to connect to an EC2 instance running Ubuntu 18.04. I'm fairly sure that this has to do with neither the * or the + register showing up in ...
1
vote
1answer
33 views

Can you run a regex on a register or the clipboard contents?

I want to copy something to a register or more ideally the system clipboard and then run a search / replace regex on it the way that I do in the buffer...is that possible?
2
votes
3answers
112 views

How to search in all registers

Is there a nondestructive way to search a pattern in all registers, like redirecting :reg to some register and then paste it to a new buffer and perform the search there?
1
vote
2answers
105 views

What's the difference between "qp and <c-r><c-r>q when you store a macro?

I used to store macros in insert mode as <c-r><c-r>q, but that fails if the macro contains a special character such as <C-Right> If I record a macro as qq<C-Right>q. the ...
1
vote
2answers
48 views

Pass character-wise visual selection to an external command

I want to VISUAL select a piece of text character-wise and pass it to an external command. For example I want to select only the URL from the the text below abcde www.google.com abcde and open it ...
8
votes
2answers
435 views

How to source a part of a file

I can source a file, e.g. my vimrc with :so % or :so <filename>. But what do I do when I need to source only part of a file. I want some way to visually select a portion of the file with :h v ...
1
vote
1answer
52 views

Vimscript or macro to “rotate” column 20 (or n) vertically?

Given an integer n and a block of text, rotate every character or element in the n-th column up or down to the next position that exists. A line with more than k characters. A longer line with more ...
1
vote
2answers
65 views

vim change instances of same identifier after `ciw`

I'm trying to make it easier to refactor stuff by running a single command that "performs the last rename interactively". I have a binding for doing this that sort of works, but I'm curious whether ...
0
votes
2answers
23 views

How to let a register contain exactly one ^M without an extra newline?

I'm trying to programmatically record a macro (using :let @m= rather than qm). In vim, I executed: :let @m = ':retab^M' where ^M is typed as ctrl+V, Enter. I expect the buffer to contain exactly ...
0
votes
0answers
121 views

Blockwise pasting from "+ register not working

UPDATE: I run an X server (XQuartz 2.7.11) on MacOS, which I forward via ssh to any Linux machine I use. The problem seems to be that under XQuartz, the "+ register does not support blockwise yanking/...
0
votes
2answers
80 views

Vim registers fast pasting with :reg view

I want to have fast pasting while having :reg view. I have remapping: :noremap <C-r><C-r> <ESC>:reg<CR> While i am in this mode I want to to have single keystroke(buffer ...
0
votes
2answers
62 views

How can I delete lines fit a pattern to a register or a new file?

I can use the powerful :g command to delete lines that contain a certain pattern like this: :g/^\va pattern/d I thought I should paste the deleted content to a new place but I cannot find all ...
6
votes
1answer
760 views

Repeat last yank

I'm appending text to "a" register with:"AyW. If I wanted to repeat last change I would use:. But in this case I would like to repeat the last yank command. Is there a command to repeat the last yank (...
1
vote
1answer
142 views

Vim: Replace visual selection without overwriting the unnamed register

How do I replace a visual selection with some register content without overwriting the unnamed ("") register by the visual selection? The question https://stackoverflow.com/questions/3837772/vim-...
0
votes
1answer
39 views

Why aren't the lines copied into my system register?

My copy of Vim has the +clipboard feature compiled in: vim --version | grep clipboard +clipboard +job +path_extra +user_commands +eval +mouse_dec +statusline ...
0
votes
1answer
42 views

what is the difference between “* and ”+?

The two registers "* and "+, what is the difference between them? Maybe they are all about OS clipboard?
3
votes
1answer
244 views

How to paste the content from dot . command

Given the word foo in a text, if I type ciwbar<ESC> while recording it as a macro in w register and then type in the command line :<C-r>w it will brings me :ciwbar^[ However if i type :&...
1
vote
2answers
40 views

Limiting the output of `reg` to only those matching a string

Imagine a situation, where you remember, that you want to re-use something you have deleted a while ago. Most likely the thing that has been deleted is stored in one of the numeric registers. Usually ...
1
vote
1answer
33 views

How to edit a register in normal mode from a script

I want to be able to write my own custom escape method. If I want to paste the contents of register s while in insert mode, I can type <C-R>s<CR>. If I want to escape all occurrences of \...
1
vote
2answers
156 views

Overwrite buffer with system clipboard by ex command

I'm trying to find the right ex command to overwrite the current vim buffer with the system clipboard. The relevant system clipboard register is "+ in this case. My first guess was to use :%+p; i.e. ...
1
vote
1answer
325 views

disable clipboard: how to set clipboard option to Black hole register?

In some editing senario, I want to do a series of deleting, and do not want to clutter with the system clipboard, which I use an external program to management the history of it. The question is, ...
2
votes
1answer
164 views

Registers ” vs @

Ok I must have missed something vital here. Can someone please tell me what the difference between using "a and @a is? All I know is that @ is used together with let and e.g. echo and ” is used when ...
0
votes
0answers
37 views

How to set system cut-buffer clipboard as default in vim? [duplicate]

I usually want to share my clipboard between vim and other applications (like a web browser) so that I can yank/paste the information easily. So questions, How do I set the default behavior of vim ...
0
votes
3answers
302 views

How to transfer a register to the system clipboard?

If I store a value in a register in vim, is there a way I can transfer it to the system clipboard using a quick ex command? Or do I need to write a macro to do that?
1
vote
0answers
39 views

Change where a register actually points (in this case, redirect “+” [sys clipboard], to an external program) [duplicate]

Setting up vim on WSL, and I want to be able to redirect the vim internal clipboard to the windows clipboard. This is possible if running an X server like XMing, but I don't want to do that. I have 2 ...
2
votes
2answers
1k views

How to replace string with register content?

For example, substitute : with register 0's content. What's the correct command for :s/:/"0/.