We’re rewarding the question askers & reputations are being recalculated! Read more.

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
0
votes
0answers
49 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? ...
1
vote
2answers
51 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 ...
1
vote
1answer
42 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
424 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
61 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 ...
1
vote
1answer
47 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 (pastingutting the content of a bufferregister, ...
4
votes
4answers
206 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
27 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
58 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
51 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
312 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
35 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
480 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
55 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
44 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
136 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
31 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
66 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 ...
2
votes
3answers
331 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?
3
votes
1answer
103 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
81 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
30 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 ...
2
votes
1answer
83 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
43 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
59 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
57 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
114 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
39 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 - "~...
0
votes
1answer
47 views

How to copy up to the cursor without including the charater under the cursor

Like you would in virtually any application editing text. For example: this is a big sentence so I can explain ^ ^ start of selection my cursor is here I'd like to ...
0
votes
0answers
17 views

Cannot seem to copy paste - using gg > yG [duplicate]

Screen attached of two terminal windows: I would like to copy the 3 lines on the left and drop them into the window on the right. Tried gg to go to the top then yG. I get a message '3 lines yanked' ...
3
votes
1answer
202 views

Paste mode sometimes inserting “<Paste>”

Sometimes when I paste (via cmd+v) some text into neovim, it inserts <Paste> at the bottom, i.e: This was pasted and I got some bonus letters <Paste> I can't figure where this text comes ...
0
votes
0answers
81 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/...
1
vote
2answers
107 views

Can I define something in .vimrc to speed up pasting of large amounts of data?

Occasionally, I paste large amounts of data into vim, using Ctrl+v in my terminal emulator (in Linux). This takes several seconds before vim is responsive again. I have tried two other methods, which ...
1
vote
0answers
65 views

Cursor position after pasting

I believe the default behaviour in vi(m) for pasting (p) or (P) was to leave the cursor at the current position as before pasting, and in order to paste a register and have the cursor be at the end of ...
0
votes
1answer
23 views

How do I delete the end-of-line to the right of my cursor?

Say I have the following text open in vi: Lorem Ipsum is simply dummy text [CURSOR] of the printing and ... The cursor position is denoted by [CURSOR] How can I delete the end-of-line that follows ...
6
votes
1answer
681 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
79 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
0answers
29 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: ...
0
votes
1answer
82 views

Copy and paste with breakindent set

I'm using breakindent to make long lines wraparound to the same indentation level as the start of the line. Unfortunately, with this setting on system copy and paste (in this case, out of the macOS ...
0
votes
2answers
48 views

How to yank a specified amount of lines in vim -E mode?

This is my first-post and question here so please be gentle (but also tell me if, it I wasn't specific enough etc...) So my questions seems rather simple to me, but still blocks me and I can't find ...
1
vote
1answer
337 views

Paste not working

File: 1111 2222 3333 4444 If I yyP on 2222, the system clipboard is pasted in, not 2222 as expected. However, :reg shows that 2222 was saved to register 0 and ". I expected it to save to th If I ...
1
vote
1answer
46 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 ...
5
votes
2answers
167 views

Why can't I paste commands into vi?

I've been using vi for 40 years. A week ago I upgraded; Disaster struck! The upgrade was to VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Mar 4 2018 23:38:28) I run this on xterm under Cygwin (...
0
votes
1answer
60 views

How to delete Chinese characters in Lisp code (solved)

EDIT. Cause of problem has been found: the problem only appears when Tamas Kovacs' Paredit plugin is enabled. I have a lisp file containing comments and strings written using Chinese chracters. The ...
2
votes
4answers
219 views

How can I overwrite a whole file with the content of another?

I have two tabs open, file1.txt and file2.txt, each with different content. How can I copy the whole content of file1.txt and overwrite file2.txt with it, resulting in both files having the same ...
0
votes
1answer
37 views

Unable to copy line with .co

Since dot (.) is the range indicator for the current line I was expecting :.co to copy the current line, but it does not do this. What am I doing wrong? In contrast :.w my_line.txt will write the ...
2
votes
1answer
66 views

Is there a text object or motion for non-comment lines are not separated from comment lines by blank lines? E.g., in git commit messages

Consider the text A B # C # D Is there a text object or motion that will select lines A and B if the cursor is on either, but not select lines C and D? ap or ip with the cursor on any of those four ...
1
vote
4answers
84 views

How do I remove first 2 characters of each even numbered line?

Suppose, I have abcd efgh ijkl mnop qrst I want to delete the first 2 character of each even numbered line. abcd gh ijkl op qrst