Questions tagged [cut-copy-paste]

Questions about cutting, copying, and pasting text. In Vim, "cut" is also called "delete", "copy" is also called "yank", and "paste" is also called "put".

Filter by
Sorted by
Tagged with
1
vote
1answer
1k views

Copy and paste by columns from one file to another excluding the common first column [duplicate]

I have 2 data files f1.dat and f2.dat. f1.dat 0 a0 b0 1 a1 b1 2 a2 b2 f2.dat 0 c0 d0 e0 1 c1 d1 e1 2 c2 d2 e2 I wish to copy all columns of f2 except the ...
1
vote
1answer
62 views

How to correctly interpret the cursor's position?

I'm having trouble understanding the cursor in the context of Vim commands, e.g. insertion, deletion, movement, etc: When the cursor is hovering over a character and I want to delete until the end of ...
1
vote
2answers
725 views

How can I use tmux for copying if I can't access the system clipboard?

I'm testing out using vim with tmux. One thing that I could do with vim with a split window is yank text from one buffer and paste it into the other. This no longer works when I have vim buffers in ...
1
vote
1answer
85 views

Yank with Separate Line Pasting

Given a b c d e I want to 5yy and then separately paste 5 lines in arbitrary locations in order of a b c d e instead of a separate yy p for each line. Are there any plugins or Vim script that would ...
1
vote
1answer
20 views

How to paste yanked filename to other application?

I'm able to paste text to other application using CTRL + V. But when I try :let @" = expand("%:p"), then paste it to the other application it will just paste my last normal yanked text, instead the ...
1
vote
1answer
67 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
33 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 "...
1
vote
1answer
122 views

how to yank from vim to system clipboard?

I'm using the latest version of vim 8.2.148 on the latest version of arch linux 5.5.6-arch1-1 with the latest version of Openbox window manager version 3.6.1. I have written a document in vim and ...
1
vote
2answers
56 views

Yank multiple lines and paste at end of lines

I have 3 blocks of text with the same number of lines that I want to merge each block by line. # block 1 [ Card "Skwortul" , Card "Scorchander" , Card "Seedasaur" , Card "Kapichu" , Card ...
1
vote
1answer
123 views

paste doesn't work in visual mode with `clipboard+=unnamed`

I am running VIM 8.1 with MacVim on MacOS. If I set clipboard+=unnamed, then when I click p in visual mode, it simply copies the currently selected text into "* and "+. If I remove this and restart ...
1
vote
1answer
166 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-...
1
vote
1answer
51 views

p (paste) but keep cursor same column

yyp pastes the current line underneath itself and moves the cursor to the start of the new line. If I start with my cursor on X: Ysiml yuipXedicious after yyp I get Ysiml yuipXedicious Ysiml ...
1
vote
1answer
603 views

How to use a value stored in a variable in the command mode?

Consider the following function function! AbbreviationsOpen() "go to the first word of the last line normal G "store the word in the register named a let @a = expand('<cword>') ...
1
vote
1answer
86 views

Copy-Paste C# style function with attributes

I have the following function: [Test] public void Some_Unit_Test_Function() { // some setup-test-assert code ... // end of code } What's the 'vim' way of copying the entire function (...
1
vote
1answer
344 views

Copying lines in visual mode only lets me paste 2 lines

I don't really know a better way to describe this, but copying multiple lines in Visual Mode flat out doesn't work. I hit V, highlight the lines, hit y, and then it will tell me "31 lines yanked" (or ...
1
vote
1answer
646 views

How to yank word from all selected lines in visual mode?

In the middle of a line, Press v and select multiple lines. How to yank the word at current cursor from all selected lines and add spaces if the word is shorter than the longest one to make copied ...
1
vote
1answer
228 views

Execute selection and redirect output to new buffer/tab

I want to automate something I started using. Short story is I have a file with some lines and I want to execute each line every now and then and see its' output, but I don't want it to override the ...
1
vote
1answer
437 views

Paste without messing up indentation in insert mode

I use Ctrl-R to paste in vim when I am in insert mode, but this , more often than, not messes up the inentation and I have to indent it manually or use =. All this makes Ctrl-R same as going to normal ...
1
vote
2answers
111 views

Refer to text between arbitrary delimiting characters

Given the following text: Hello Part1/Part2 Bye With the cursor on top of any character in Part1/Part2 I would like to be able to refer to the whole Part1/Part2 (for visual selection, deletion, ...
1
vote
1answer
2k views

Vim says I don't have solarized colorscheme whereas I have that

Vim gives me this error :- Error detected while processing /home/piggy/.vimrc: line 23: E185: Cannot find color scheme 'solarized' Press ENTER or type command to continue But I can change to ...
1
vote
1answer
36 views

How would I modify this function to restore from a specified register?

Currently I have the following mapping in my vimrc nnoremap d "_d nnoremap D "_D nnoremap C "_C nnoremap c "_c nnoremap <leader>d "*d nnoremap <leader>D "*D" The result of the above ...
1
vote
1answer
202 views

Vim not displaying deleted text correctly in tiling WM

I'm sorry if the question doesn't make much sense, but I really don't know how else to describe it. I'll do my best to clarify. Let's say I have a text file containing the words here is some text ...
1
vote
1answer
17 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 ...
1
vote
1answer
43 views

How to automatically perform a command after yanking text [Vim wayland clipboard]

I want to copy contents of the recently used " register automatically into my system clipboard after a yank command. The way I achieve this now is by nnoremap <C-@> :call system("wl-copy", @")&...
1
vote
1answer
338 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, ...
1
vote
0answers
48 views

Vim adding blank line after each line when pasting from clipboard

When I copy-paste multiple lines from clipboard into my vim, it inserts a blank line after every line. But when I copy in into a text editor first and then copy-paste it into vim, the blank lines are ...
1
vote
0answers
30 views

losing random chars when pasting (insert mode + :set paste are set)

When pasting a huge text (10,000 lines, around 500KB) in vim (yes, I'm using insert mode and :set paste), I lose random characters every few lines. I thought it could be a plugin, so I tried starting ...
1
vote
1answer
18 views

Problem pasting text with brackets when using auto-close functions/plugins

It's nice to have an auto-close plugin for brackets and quotes like coc-pairs. However, when I paste text from outside into vim insert (ctrl-C, ctrl-shift-v), the text seems to be pasted character-by-...
1
vote
2answers
51 views

Pasting text on Vim inside tmux breaks indentation

Ubuntu: 18.04 bionic tmux: version 2.6 VIM: Vi IMproved 8.0 (2016 Sep 12, compiled Jun 06 2019 ) Included patches: 1-1453 Modified by pkg-vim-maintainers@lists.alioth.debian.org Compiled by pkg-vim-...
1
vote
0answers
35 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 ...
1
vote
0answers
23 views

Problem copying form vim to system clipboard [duplicate]

I usually do this with "*y (from visual mode), but on the linux box I'm working with (lubuntu) when I press * after " in visual mode, vim doesn't insert * (it just ignores the whole "*). If I check * ...
1
vote
2answers
67 views

How to efficiently use the paste registers?

I often don't remember what was copied lately. So I don't know if I need to do <C-r>0 or <C-R>1 in insert mode. I tend to rely only on the * register, or type :reg, look at everything ...
1
vote
0answers
39 views

Update OS enviroment variables from inside VIM

I use vim inside tmux over an ssh session and I often run into the issue where the $DISPLAY variable gets changed, screwing up my copy-paste. When I log in, $DISPLAY gets assigned to something new: ...
1
vote
1answer
73 views

Pasting from register to command line inserts ^M instead of new line

Say I want to search for multiple lines (or do anything with them in the command line). I yank some lines and enter search mode (/). I press Ctrl + r" to paste what I just yanked, but I get ^M for ...
1
vote
0answers
417 views

Disable paste mode entirely

I get what paste mode does for you, but I have never found it particularly useful. I would like to completely deactivate it. I don't see an option to do so when looking at :help paste. However, I ...
1
vote
0answers
27 views

Yanking a visual block with word wrap enabled is shifted

Say I have a file with the following contents (on a single line): Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed augue ligula, venenatis et orci non, convallis congue nunc. Nam eleifend ...
1
vote
0answers
61 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 ...
1
vote
0answers
60 views

Yank only matched unique strings of a pattern in lines to a register? [duplicate]

I have a file containing lines in the following form: this is line 1 and this is line 2 and this is line 4 and this is line 8 and 23, and this 56 should not be yanked this is line 9 and this is line ...
1
vote
0answers
433 views

linux: yank to clipboard, cut to primary

I'm using neovim. I want to map the 0 register to the system clipboard and the unnamed register to the system primary (mouse middle click). Is it possible? I can map the unnamed register to primary ...
1
vote
0answers
28 views

How to get vim to use the same register as X? [duplicate]

I would like to be able to yank and paste text from and to X clipboard (webbrowser, email client etc), is there an easy way to fuse the registers to have a single clipboard ?
1
vote
0answers
655 views

How can I reliably copy and paste between vim and other programs? [duplicate]

I have a hard time just copying and pasting between vim and other programs (firefox, chrome, gnumeric) as well as other instances of vim. Normally I try to copy/yank with "+y and paste with "+p. ...
1
vote
0answers
29 views

Is there a way to reselect the last pasted text, rather than the last actual selection, starting at the current cursor position? [duplicate]

I know that gv reselects the last visual selection. This is great and I use it frequently. But sometimes I want to select the block of text that I just pasted. This is useful e.g. for sending example ...
1
vote
0answers
18 views

do a command without altering the register [duplicate]

Sometimes I delete a line and when I want to yank it somewhere else I found out that I need to delete another line. How can I delete the new line without overriding the the content of the line that I ...
0
votes
2answers
28 views

How to delete strings to close quote and close parenthese

I have a code like this: h5 style=("text-align: center; margin-top: 2rem;") some text p style=("text-align: center; margin-top: 2rem;") some text And in first line, I want to ...
0
votes
1answer
35 views

Yank once then multiple paste [duplicate]

My cursor is on line 10. How can I yank line 5 and paste to lines 10,20,30,40, and 50? I know :5 yank then navigate to each line and then P, how else can I do this?
0
votes
1answer
53 views

Delete word around cursor and move to insert mode

My Problem Going from: To: I'm doing some editing (interactive rebase on a git repo, but the problem is generally relevant). The cursor is on a word (pick), and I would like to delete it , ...
0
votes
2answers
146 views

Is visual model selection really faster than using mouse? [closed]

I am interested in finding the faster way to edit. My monitor is rotated 90 degrees vertically. When I code, I can see more lines than a typical monitor. I found that using mouse to select is faster ...
0
votes
1answer
15 views

How to delete and replace a block of text with spaces?

What I want to do I want to select a block of text in Vim, delete it, and replace the selected block with spaces. Example Suppose I have the following text: Lorem ipsum dolor sit amet, ...
0
votes
1answer
40 views

Better way to copy paste previous word using vim's default keyboard sequences?

Recently I have been documenting a lot of code which are usually in markdown files (.md). And I frequently come across texts where I have to retype previously written word. Like, cp file_1 file_2 mv -...
0
votes
1answer
42 views

Delete from the next character till EOL

My problem Consider the following line: I have just pasted @SrvrlessDaysTLVtlv before tlv@serverlessdays.io, and I'd like to delete anything from the small-case t till EOL. What have I tried d$ ...