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
0answers
34 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
25 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 ...
0
votes
1answer
29 views

Stop the normal mode delete commands from copying text

When editing text, I find it quite irritating that the normal mode commands, x, d and s all copy the text they remove. Don't we have y for copying? Perhaps I am "just doing it wrong", but for example ...
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.
2
votes
2answers
83 views

How to activate bracketed paste mode in GNOME Terminal for Vim inside tmux

Edit this issue happens inside a tmux session. The original value of $TERM before starting vim is: echo $TERM screen The issue appears for example when pasting this kind of indented code: def ...
2
votes
4answers
100 views

Clipboard is reset after first paste in Visual Mode

I am on Neovim. This is really annoying and weird. When I make a selection in Visual Mode and copy, then select a text and then paste, this paste only works once. For the next time, I again have to ...
1
vote
1answer
11 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-...
0
votes
1answer
33 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?
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 ...
1
vote
2answers
51 views

Why does <F22> appear when pasting into Vim?

I want to paste some text into Vim in GNOME Terminal on Ubuntu 20.04. Before doing that, I run: :set paste I use that so that autoindent and other Vim features don't change the text that I am ...
3
votes
1answer
129 views

How to copy paste one value and overwrite another

A common function I do in textmate or any other editor is copy some text and then paste it over some other text, for example: https://gyazo.com/fcef05504e83b608b583af085f92ecd2. Currently to copy a ...
1
vote
1answer
50 views

Can't copy special characters outside of vim

I'm using NVIM v0.4.3 with set clipboard=unnamed. I can insert special character like üäö in vim just fine, but if I copy content containing special characters in vim and try to paste them outside of ...
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. ...
0
votes
1answer
32 views

How to copy N words under cursor and to right of cursor?

How can I copy continue close current into buffer without getting into visual mode? That is, how to copy N words from cursor?
1
vote
1answer
36 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
4answers
301 views

How to delete a pair of parenthesis with backspace

I'm using vim to code C++ and I want to handle the parenthesis more easily. I knew that there was a plugin named Surround, which can help us but it is not what I expected. I set some shortcuts as ...
0
votes
0answers
21 views

Automating a yank and paste operation

If I want to copy and paste the next 5 lines and paste those 5 lines below the next 5 lines, I would do 5yy5jp. How would I use command to say something like 5yyp to paste the next 5 lines and ...
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
3answers
564 views

Deleting without copying to clipboard in Windows?

Here is a typical workflow I would like to follow: copy some data from Excel spreadsheet into the clipboard in vim , delete the data in the file using ggdG then paste the data into the file from the ...
2
votes
2answers
65 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
19 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
75 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
40 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
112 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
26 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
37 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
94 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
98 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
53 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
283 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
113 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
106 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 ...
8
votes
2answers
563 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
85 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
16 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
732 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
66 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
112 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
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 ...
8
votes
2answers
495 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
194 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
346 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
31 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
382 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
130 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?

1
2 3 4 5 6