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
2
votes
2answers
58 views

Search and copy the text between two markers in gvim

I want to copy strings that spans across multiple lines between two markers in a large file. In the below example file, start marker is <ROW> and end marker is </ROW>. <ROW> &...
0
votes
1answer
18 views

Delete to the end of a paragaph, including all of the current line

I'd like to redefine the { and } motions to operate "linewise" when used with the c and d operators. To be concrete, given the following: The quick brown fox j|umps over the lazy dog If I press d}, ...
1
vote
1answer
40 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
28 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-...
2
votes
3answers
85 views

Delete specific character on previous line

I deleted lines in a file with :g/^\s*key3/d and now have a file like this: entry{entryname1, key1 = {text}, key2 = {text}, } entry{entryname2, anotherkey = {text}, yetanotherkey = ...
0
votes
1answer
21 views

Normal mode Backspace and Delete

If I have a file like this in Insert Mode (pipe is cursor): Sunday | Monday I can press Backspace or Delete to remove the empty line. However in Normal Mode, neither of those work. I have been ...
0
votes
2answers
32 views

Paste at cursor instead of below

If I start with this file: https://example.com <> and press ddp, I expect to get this: <https://example.com> but instead I get this: <> https://example.com What am I doing ...
3
votes
1answer
89 views

Is it possible to place marks at the end of a line?

Typical mark placement using m places the mark at the cursor. When the cursor is on the last character of a line, this means that jumping to that mark for the purpose of copying text starts the ...
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 ...
2
votes
1answer
61 views

Paste a block in “replace” mode

This is best explained with an example: Start by block selecting some text: Yank and paste it somewhere else: Note that the existing x characters were pushed over to the side, rather than being ...
1
vote
2answers
46 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
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
279 views

Duplicate single char with the shortest keys combinations

Lets say I have "string" and I want to dupplicate the double quotes. What is the shortest way to do it?. I have done a search of double quotes using /". Then I navigate to the different occurences ...
1
vote
2answers
60 views

How to override netrw-delete behavior

I'm currently using Vim 8.1 on Ubuntu 18.04, and I would like to override the default behavior of deleting local files/directories 'forever' when using netrw. The doc says that this plugin uses a ...
1
vote
1answer
77 views

Yank then Paste without moving cursor

I want to be able to: :42y then something like: :13p having it to paste the yanked line in a new line after 13, without taking my cursor away. So far, all solutions I have found involves going to ...
7
votes
2answers
518 views

Difference between “* and ”+ registers in +clipboard VIM?

"*p and "+p seem to behave the same. I tried :help "*, but it's talking about mouse selection, and :help "+ tells me There are three documented X selections: PRIMARY (which is expected to ...
4
votes
1answer
25 views

Cursor Movement in y8k vs y8j [duplicate]

Why does y8j not move the cursor but y8k does move it up? What .vimrc entry would prevent yanking upwards moving the cursor?
3
votes
3answers
71 views

Using :g to yank in quotes across multiple lines

I was reading through the vim wiki about the power of g https://vim.fandom.com/wiki/Power_of_g and would like to do something similar to :g/pattern/y A but a little bit different. I have an html file ...
4
votes
0answers
11 views

How to copy text to X primary selection only when visual mode is started with the mouse?

At the moment, if I use Visual mode, whenever I select a block of text using the keyboard it ends up on my X primary selection (ie the clipboard that is filled using the mouse). Even if I just select ...
3
votes
4answers
727 views

Last char on the line is being “left out” in many situations

For example, wanting to delete the last 3 words from the current line, I press $d3b but I still have the last char from that line not deleted. Is that normal? Is there a better way to achieve what I'm ...
0
votes
0answers
63 views

Move/copy range to start of current line

I just learned about the shortcuts that allow you to manipulate ranges, e.g. :+5,+10co. to copy after the current line. I wondered if there is a way to copy and move at the start of the current line? ...
3
votes
2answers
100 views

Is there a way to paste at multiple locations/lines in vim?

I use :copy a fair bit. So like range :12,15 copy 20 will paste a block of text from 12 to 15 lines at 20th line. But when I want to paste a line at multiple places it doesn't work. For example :24 ...
2
votes
1answer
53 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 ...
8
votes
2answers
486 views

How to move a paragraph and paste it without an initial newline first

If I have a pair of quotes on a line by themselves: '' ...and a short paragraph of text, say three lines of text: some text that I'd like to move Now if I want to move the text into the quotes, I ...
1
vote
1answer
135 views

How to paste text after each line matching a pattern?

I have a file like this: int var; int f() { // Use of var } int g() { // Use of var } int h() { // Use of var } // ... I want to move my global var into each function to get this ...
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
262 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 ...
0
votes
0answers
11 views

Artificial indenting with shift+insert [duplicate]

When I paste via SHIFT+INSERT, vim create artificial indent per line. How can I paste without any indenting?
1
vote
1answer
30 views

visual block copying didn't work

I have the following lines autocmd filetype tex nmap <d-p-1> cha autocmd filetype tex nmap <d-p-2> sec autocmd filetype tex nmap <d-p-3> sub autocmd filetype tex ...
2
votes
1answer
217 views

How to copy long line from terminal buffer as it is without adding new lines?

I wanted to copy a public key from one machine to the other. I opened up vim and had two terminal buffers - one for each machine. In the terminal in which I had the first machine I went into normal ...
2
votes
1answer
101 views

copy or yank from line x until line y

I know about :yN for example , :y10 , yank 10 lines from current line. I need to yank from line 73 until line 81, How can I do it?
0
votes
2answers
829 views

Make vim support the Windows clipboard

I've found a lot of information online about this for Linux-Vim but not for the Windows-Vim (not gvim). Whenever I try to copy and paste something in Vim (using y and p), the copies I make do not ...
0
votes
1answer
42 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 , ...
1
vote
2answers
667 views

Copy entire line and paste it after another line

Let's say I'm at line 20 and I want to copy (and paste below line 20) just the line 50. I can do that with :50,50y , then paste with p in normal mode. I found this here. I want to know if there are ...
2
votes
0answers
20 views

Different behavior when selecting quote blocks vs. selecting parentheses blocks [duplicate]

When I have a line of code such as: result = function(myVar); then I can delete the text "myVar" with the command di( only if my cursor is already positioned inside the parentheses. However, when I'...
3
votes
2answers
57 views

Why is this appearing to select wrong number of lines?

First, I typed 2V to select two lines, and y to yank them. Then I typed 3V, and instead of selecting 3 lines, Vim selects 6 lines. Next I typed 4V and Vim selected 8 lines. It seems that 3 or 4 in the ...
1
vote
1answer
49 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 ...
0
votes
3answers
269 views

Is it possible to yank a column of text in vim without visual block mode?

Consider the following text file. 1 1 3 1 1 5 One can rank row 1 with the command y$ with the cursor on row 1, column 1. However, to yank the first column, the only way I know is to <C-v>3jy. ...
0
votes
0answers
33 views

Quick paste via single keybind

As I understand, the default cursor looks like this: ▉ block. Currently I have these related settings: set guicursor=c-n-i-v:ver25-blinkoff0 And ver25 makes the cursor look and behave as if only ...
0
votes
1answer
82 views

Multiline paste with relative columns alignment

When I have some text indented as follows (like a and b variables assignment): if(condition) a = 1; b = 2; end and I want to paste a and b block somewhere outside of the if block, i.e just ...
3
votes
3answers
705 views

How to copy lines with line numbers?

I would like to copy several lines with line numbers; the text from set number isn't copied. Is there any way to do this?
4
votes
1answer
154 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
2answers
109 views

How to copy file and line info from vim to gdb?

For setting breakpoints, I was wondering if there is any way to copy the location of a line in a file opened in vim, to gdb rather than typing the whole file path and linenumber in the gdb shell?
0
votes
1answer
34 views

How to paste several lines to a new buffer without extra empty line?

Suppose you have 5 lines in current buffer among others. You yank them using 5Y, make a new buffer with e.g. tabe, and try to paste these 5 lines so that they are the only thing the new buffer would ...
3
votes
1answer
120 views

How to paste the clipboard selection when it was populated with a yank in Vim started from the st terminal?

If I yank some text in the clipboard selection from Vim (e.g. "+yiw), then quit Vim, I can't paste it in st. Here's a MWE: $ git clone https://git.suckless.org/st $ cd st $ make $ ./st $ echo foo | ...
0
votes
1answer
49 views

How does deleting words with `d[number]w` work?

If my cursor is between the words "because" and "and" in the following text, typing d2w in command mode deletes everything in between "because" and "su without". because and su without After ...
-1
votes
1answer
65 views

How to copy and paste arguments into function parenthesis?

I constantly need to copy existing variable names or expressions as arguments for my current typing function: // int TyrionLannister; int JonSnow; ... int AryaStark; ... // int DaenerysTargaryen;...
1
vote
1answer
73 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 ...
5
votes
2answers
115 views

WORD movement across lines

Consider the following text snippet: value1, value2 Now, if the cursor is at (1,1) (the 'v' of value1), W takes me to (2,5) (the 'v' of value2) which is as expected. But if I do dW at the same ...
0
votes
2answers
40 views

How omit text between and including matching characters?

If I have a text containing markdown matching markings e.g. "Strikethrough uses two tildes. ~~Scratch this.~~" What would be a good way to delete all those occurrences such as - in this example - "~...

1
2 3 4 5 6