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
1answer
39 views

Text get weird staircase indent on copy

I copied this file to vim and enumerated items got weird staircase pattern indent. Why so and how can I prevent this text corruption on a copy? It seems that it happens not only with enumerated items ...
2
votes
2answers
161 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
1answer
158 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 ...
2
votes
1answer
64 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 ...
2
votes
1answer
157 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?
2
votes
3answers
184 views

How to append <cr> to a register from a yank?

I am actually stuck level 10 at vim-adventures, but this question concerns vim in general. I have a new file with this content: 99 bottles of beer If I yank the line with "aY I get 99 bottles ...
2
votes
1answer
86 views

How can I define an operator that takes a register as an argument?

I'm trying to write a "Paste-over" operator. It will work like a combination of p and R, so it will paste the contents of a register over the text currently in the buffer. I have this so far: ...
2
votes
1answer
503 views

Cut and copy : Blackhole and default register assignment

I currently have something like this in my vimrc. The reason i have this is because I do not want items to be copied to the default register when I delete or change. "Copy the contents of delete to ...
2
votes
1answer
289 views

Why does pasting screw up my text file and shell script?

I'm using Vim on Ubuntu 14.04 LTS. I've been confused by these two situations and I think they might have common cause: When I open a text file in vim and paste some content that I copied from web ...
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 ...
2
votes
1answer
947 views

How to disable bad indentation when pasting text?

I am using vim and simply want to disable auto indent when I paste text into my terminal vim session. I have tried numerous solutions including various incantations of below to ~/.vimrc: set nopaste ...
2
votes
1answer
623 views

Yank/select until delimiter in different lines

From the following text: variable1 = 'example' foo = 'foo' barett = 'ver' I would like to yank (or visually select, if possible) the content of each line until the = sign: variable1 foo barett ...
2
votes
2answers
279 views

Cut and then paste at the beginning of the line

An example: Doe, John And I want: John Doe I cut Doe with D, and then 0 and then p But what I get is this: DJohn oe, How to do this right?
2
votes
1answer
52 views

What captures the <Shift>+<Ins> key combination?

When I press SHIFT+Ins in vim to paste text, who captures this key combination? Is it the terminal or Vim? How about in gVim?
2
votes
1answer
1k views

How to copy multiple lines and paste at the end of a file

Suppose I have a file: class X(arg): \t#blabbla \tdef fun1(arg): \t\tsome code \n \tdef fun2(arg): \t\tsome code \n class A(arg): \t#blabbla \tdef fun0(arg): \t\tsome code \n \tdef fun3(arg): \t\...
2
votes
1answer
122 views

How do you get which “side” of the visual mode selection the cursor is on in vimscript?

I'm writing some vimscript and would like to preserve the cursor position after a yank occurs in visual mode. Ths issue is that I can't find any way to get the cursor position while in visual mode. ...
2
votes
1answer
626 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
2k 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 ...
2
votes
1answer
138 views

Delete wrapped lines?

How to delete wrapped lines? I imagined something like gdd and gD but they did not work as expected, in a similar fashion to gj and gk to move through wrapped lines. It would be really useful to ...
2
votes
1answer
48 views

Yank visual selection with modifications in a terminal-buffer

Upon writing a code, sometimes I open a terminal split with :term to test it by issuing some commands and checking some output. As an example, this is a fragment of what I have executed in a split ...
2
votes
1answer
50 views

Can't Copy Non-ASCII Characters

I can't copy Non-ASCII charaters from Neovim anymore when I select them with mouse or crtl + v. For example, I have the Turkish word Bankası written in my editor. When I yank and paste it to somewhere ...
2
votes
4answers
452 views

Paste in normal mode ignores autoindent

When I paste something within normal mode, vim ignores autoindent. I copy and paste with y and p. As mentioned autoindent is on. It works fine when I manually indent or type something before pasting. ...
2
votes
1answer
350 views

Issue with using ex commands

I asked a question a few days ago in the Linux/Unix SE about how to copy a block of text from one file to another in a way that I could use for a script of many similar files. I thought I came up with ...
2
votes
0answers
34 views

Copy all text in Vi and then paste it to another application on another system

I connect to Linux server via SSH using Putty terminal. I open a file with Vim and press ggVGy in order to select all text and copy it. But when I try to paste the copied text to Windows Notepad, it ...
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 ...
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'...
2
votes
2answers
206 views

How to replace pattern in multiple lines with different replacements?

I have a line that fits a "template", and multiple pieces of "data". For each piece of data, I want to copy the template and replace all occurrences of a pattern in that line with the data. I'm using ...
2
votes
0answers
58 views

Command to delete inside parentheses doesn't work [duplicate]

Let's say I have a line of code: for i in range(1, 100): My cursor is on the f in for, and I want to delete the text inside the parenthesis. In other words, I want my line to look like this: for i ...
1
vote
2answers
286 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
1answer
151 views

Can I yank from the current position of the cursor to the end of the line without the newline?

I've got a list of files that I want to copy from one place to another, I need to change the name slightly and I'd rather copy the file names instead of typing them over and over again. If I do YP I ...
1
vote
4answers
90 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
1
vote
3answers
940 views

Copying and pasting while inserting

When I am inserting a big block of code or text, often I will want to copy and paste text from elsewhere into that block. Is the only way to do this to leave insert mode, go get the text and paste, ...
1
vote
2answers
182 views

How can I delete a quotation mark and comma at the end of every line?

Suppose I have the following text, how can I delete single quotation marks and comma in each line end? I know I can use x command and delete ' and , line by line. But are there any more clever way to ...
1
vote
2answers
367 views

How to select/delete/yank the contents of only the current fold?

When using foldmethod=marker, how do you select or reference exactly the contents of the current fold? I want to swap the order of two folds. If they were paragraphs, I would do dap { p. However, I ...
1
vote
3answers
600 views

Is there any way to copy a entire function without indicating line number?

I have a file.c containing #inlcude<stdio.h> int main() { printf("Hello world\n"); } I can copy the main function using :3,6y. But, when the function is big enough then in order to ...
1
vote
2answers
135 views

Why so many keystrokes to duplicate a word with an edit in between them?

Let's say I want to edit the text blahblah WombatModeFunctor to be blahblah WombatModeFunctor::WombatModeFunctor The way I know to do it is: Move the caret (cursor) until it is over the W Use yw ...
1
vote
1answer
227 views

What can happen if I accidentally paste into command mode? What should I do if I do this? [duplicate]

If I have vim in a windowed terminal, sometimes I paste (using the terminal's paste functionality, e.g. middle click) from another window that isn't vim. Most of the time, when I do this, I wanted to ...
1
vote
2answers
59 views

How can I paste text appending it to the end of each line? [duplicate]

If I have file1.txt which contains the following: Line 1.1; Line 1.2; Line 1.3; and file2.txt with the following Line 2.1; Line 2.2; Line 2.3; I want to copy all the lines of file2.txt and paste it ...
1
vote
1answer
68 views

Wrapping lines in a paragraph with header and footer lines

Say I have a paragraph like this line1 line2 line3 I want to select all and then transform like this :start line1 :end :start line2 :end :start line3 :end Don't ask me why, we have some strange ...
1
vote
2answers
399 views

Don't yank character with <DEL> key in normal mode

I am using NeoVim with Tmux on an Ubuntu on Windows setup. I have bound neovim's clipboard to the system clipboard by using : set clipboard+=unnamedplus and further configuration inside tmux. So far, ...
1
vote
2answers
317 views

How to set up Crtl-v map that works in insert mode?

What is the best way of linking the Ctrl-V key combination to pasting the clipboard in insert mode? I used map <C-v> "+gP imap <C-v> <C-r><C-p>+ in .vimrc. However in ...
1
vote
2answers
58 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 ...
1
vote
1answer
72 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 ...
1
vote
2answers
81 views

How to remove a line and paste it at the beginning of a range

How to remove a line and paste it at the beginning of a range? line 1 line 2 line 3 line 4 xxxxxxxx For example, here I want to remove the 5th line and paste it before the first two lines, to change ...
1
vote
1answer
43 views

Map key to paste and immediately select

I know I can select pasted text using this trick mapped to gp. That means if I paste and then want to select the pasted block, I need to say p and gp. I want to paste and immediately select that, ...
1
vote
3answers
136 views

Copy a line, comment it and replace a word in copied line

Libraries evolve all the time and I often face the situation where after an update some function name have changed and they return errors in the updated version of the library. It's easy to replace ...
1
vote
1answer
43 views

Indenting now add suspicious chars to my files when pasting

Following answer I got there to allow >> to indent, I edited my .vimrc to this: :set shiftwidth=2 :set autoindent :set smartindent But now when I copy/paste (via putty), it indents incrementally, by ...
1
vote
1answer
89 views

Yank multiple lines without using visual mode

I have the text: abcd abcd abcd abcd my cursor is in the first line, and I want to yank the first 2 lines. Usually I would do it by pressing Shift+v, selecting the second line by going down with j ...
1
vote
1answer
86 views

Custom g:clipboard results in `p` always pasting into the same line

Background I use wayland and neovim and when pasting external text it would add ^M to the end of each line. This is a known "bug" (https://github.com/neovim/neovim/issues/10223) and there ...
1
vote
1answer
59 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 ...

1 2 3
4
5
7