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
0answers
30 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 ...
0
votes
1answer
29 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 \...
1
vote
1answer
29 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 ...
2
votes
0answers
51 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 ...
3
votes
1answer
95 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 ...
0
votes
0answers
28 views

Is there a way to load the contents a macro I recorded the next time I open vim? [duplicate]

Say after I recorded a macro the following is in register e: Is there a way to set this register contents on demand? For instance let @e=' ' ?
0
votes
1answer
19 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?
0
votes
3answers
73 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?
0
votes
1answer
40 views

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

I used to store macro in insert mode as <c-r><c-r>q, but it failed if the macro contains special character such as <C-Right> If i record a macro as qq<C-Right>q. result of &...
0
votes
2answers
29 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 ...
7
votes
1answer
357 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
43 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
43 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
20 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
69 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
43 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
39 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
623 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
63 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
38 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
150 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
39 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
32 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
97 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
272 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
93 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
199 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
37 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 ...
1
vote
2answers
327 views

How to replace string with register content?

For example, substitute : with register 0's content. What's the correct command for :s/:/"0/.
7
votes
1answer
371 views

Strange vim/xterm interaction: auto-insertion of `"` register when opening file

This one is driving me mad. I'm using XTerm(330) and the latest vim 8.0.1365 (on FreeBSD). Sometimes, not always, about 1 in 5, when I open a file with vim, a funny line is inserted above line 1. ...
2
votes
2answers
60 views

How do I replace a word without putting the word into a register?

Right now I press ce to replace a word. However, this overrides anything that was in my register before. How can I replace a word and go into insert mode after without replacing what was in my ...
4
votes
4answers
1k views

How to concatenate two registers?

Is there some built in functionality in Vim to merge the contents of two registers into a single register by appending the two?
3
votes
1answer
41 views

How to check if a pattern is contained in a register's content?

I'm writing a new plugin and as part of a function, I need to check that a register contains a particular pattern. I checked the official documentation but couldn't manage to use any of the search() ...
1
vote
1answer
33 views

How to get a variable with the contents of a file on the filesystem?

I intend to use this to optionally share the search buffer between different Vim instances. I'll have a file on the filesystem that contains the content. So it means I need to set the search register ...
1
vote
2answers
177 views

Viminfo truncates named registers. Setting to increase limit?

I save quite a few lines into a named register "iy100l. I can then paste from that register just fine, "ip. I close and reopen Vim then try to paste from that register again "ip but it's truncated to ...
3
votes
1answer
385 views

How to delete blocks of text which contain a specific string?

I have a file which has the following structure From: foo@example.org Subject: Bar Date: 2017-06-27 Mailbox: /some/dire/ctory <CR> Such a block always contains of four lines followed by an ...
-1
votes
2answers
189 views

Can't reassign local variable value from register?

Given the following block of text: title,tags Run-ons - Comma Splices - Fused Sentences Rule 1 - Run-ons - Comma Splices - Fused Sentences Rule 2 - Run-ons - Comma Splices - Fused Sentences Example ...
0
votes
1answer
27 views

Clear the contents of a permanent register or yank to it without appending to it?

I have a permanent register "T and it's filled with something already. When I yank something else into it, it's appended to the register. I'd like to clear out just that one register so I can yank ...
1
vote
0answers
58 views

How to find out the default system copy register? [duplicate]

I want to know how to find the default copy register on any machine. I ssh into different machines and use vi. But on some of them the "+ and/or "* registers don't work. Also when I can use my mouse I ...
3
votes
1answer
81 views

What is the rationale behind not using the numbered registers for small deletes/yanks?

This is related to this previous question: Numbered register doesn't record most deleted text within a line? I want to know the rationale for this. I was writing an email and deleted a note in ...
3
votes
1answer
116 views

Why does the unnamed register only contain the last deleted text when appending deleted text to a register?

The Vim documentation says the following under “quote_quote” about the unnamed register ("): Vim fills this register with text deleted with the “d”, “c”, “s”, “x” commands or copied with the yank “...
6
votes
2answers
194 views

How to store all occurrences of a multiline search in a register?

I'm not sure if I've failed at searching for the answer to this, but now I've worked it out I wanted to document it here. The problem is searching for a multiline pattern, and storing all such ...
1
vote
3answers
184 views

How to exit the registers list with q?

When using the :oldfiles command, I can easily exit the list with q. When I use the :registers command, it says "Press ENTER or type command to continue". But I would like to exit the list with q, ...
4
votes
2answers
220 views

Get list of lines that begin with a pattern

I have two files written in php, both with a bunch of functions. I need to compare these function names with the other file, so I'm trying to get a list of all lines that begin with function. ...
7
votes
2answers
1k views

Copying multiple words (from different lines) and paste them at once

I want to copy different strings from different lines of the file and then paste them together at once. In other words, I want to collect different words in a basket and then paste them at once. How ...
1
vote
1answer
38 views

How can I use a register with :find?

I'm trying to improve my vim-abilities. I'm writing a command and a function to find the current Word under the cursor. What I want to be able to do is type :FindFile and have the word under the ...
1
vote
1answer
40 views

How to assign a search range selection into a register?

I'd like to assign the result of search range selection into a register, instead of printing it, e.g.: :/pattern1/;,/pattern2/p What syntax I can use to achieve that?
4
votes
2answers
145 views

Is there a way to strip the contents of register before pasting

There are times I know I just want to paste the content of the register inline where my cursor is, so the initial and trailing whitespace (newline, tab, etc) is not wanted. Because selecting contents ...