2022 Developer Survey is open! Take survey.

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

Yanking results displayed in status line

After pressing <C-g> in normal mode, prints useful information in the status line. How can I yank this text?
user avatar
0 votes
1 answer
16 views

Indentation is messed up when pasting code

I find that the default indentation support for pasting is lacking. For example , If I use ]p for the following(copied using V) : try: l=None if 1: df = ...
user avatar
  • 1,114
1 vote
1 answer
31 views

Is it possible to keep folds saved when I copy from one file to another?

I've recently discovered I can fold blocks of code with Vim by using zf.Then I can open and close them with zo and zc... I've also seen this solution on StackOverflow that has a vimrc configuration ...
user avatar
  • 375
0 votes
0 answers
28 views

Output of paste into vim truncated

I am having issues with pasting text from the clipboard into vim (v7.4) on an HPC cluster using Centos, which I have logged into using MTPuTTY. This is the result of pasting into e.g. sublime text: ...
user avatar
0 votes
1 answer
43 views

Copy to clipboard and cut at the same time?

I often copy to clipboard into other programs (changed to <leader>y) is there a way to copy to the clipboard and delete once copied in one command? For example, I want to press <leader>y, ...
user avatar
  • 75
3 votes
1 answer
66 views

Duplicate selected lines programmatically

I'm creating a Vim script and a critical part of it is duplicating the selected lines. To duplicate lines, I have this mapping which works as intended: vnoremap <Leader>d :copy '><CR> ...
user avatar
0 votes
2 answers
51 views

Stop Vim from yanking visual selected text

Let's say I have a file like this (abc) (123) (456) I want to yank abc and paste it in place of 123 and 456. I would yi) on the first line. Then go down a line and paste it with vi)p. But for the 456,...
user avatar
1 vote
0 answers
17 views

Delete javascript backtick string

In Javascript you can write multiline strings like this: s=`hello world` I would like to delete/yank the inside of the string by pressing di` etc., however that doesn't work. What do I have to add to ...
user avatar
  • 111
0 votes
1 answer
51 views

How can we get the third mouse option with cut,copy paste in neovim?

I am new to neovim and using the default terminal in ubuntu for neovim. With the default terminal, we can click the right mouse and get the functioning options for cut,copy and paste. How can I get ...
user avatar
  • 103
0 votes
0 answers
24 views

How to paste append and verical aligment multiple lines text in vim?

Is there any convenient way to format text block-1 to block-2 by vim? block-1 #include <stdio.h> #include "math.h" #include <iostream> #include <fstream> #include <...
user avatar
3 votes
1 answer
81 views

How to reserve a dd into a register, so I can yank it immediately even after a couple more dd's in between

dd puts the text I want to yank, in some register. Before a yank, a couple more dd's, now the first dd register has changed. How do I yank so that it's the first dd I want. I can't keep track of ...
user avatar
  • 145
0 votes
0 answers
45 views

Yanking to system clipboard does not work

I'm on Ubuntu 20.04.3 LTS, I have +clipboard and +xterm_clipboard in my vim --version, and I have set set clipboard=unnamedplus in my .vimrc. For some reason, yanking still does not copy to the system ...
user avatar
  • 165
0 votes
2 answers
69 views

"Copy" is greyed out in the Terminal menu after "Select All" in "VIM embedded in Terminal"; VIM copy does not work. How to copy the full file text?

I have set VIM as the default editor in the Terminal. I changed the ~/.bashrc: export VISUAL=vim export EDITOR="$VISUAL" You can also set the default editor only for git: git config --...
user avatar
-1 votes
1 answer
44 views

copy whole line to system clipboard even if not visible on screen

How to copy a whole long line to system clipboard even if the full line is not visible on screen? The line is very lengthy that it doesn't fit the screen even with wrap on. I need to the copy this ...
user avatar
2 votes
1 answer
87 views

Emoji does not render correctly when yanked from Neovim and pasted into a macOS GUI app like TextEdit

My issue I am new to Neovim/Vim, and I am using the Neovim from Scratch config as a starting point. It works well for me for the most part. I have a peculiar encoding issue affecting emoji that ...
user avatar
2 votes
1 answer
86 views

better copy-paste multiple lines in visual mode where vim pastes after that visual chunk of code

I want to select multiple lines in vim, copy them, and paste after that chunk of code (with cursor at the beginning). yp doesn't work because in visual chunk of code, vim pastes after the 1st line of ...
user avatar
  • 111
3 votes
0 answers
42 views

Pasting from vim to an ipython terminal

I have an open ipython terminal open, and I'd like to paste the visual selection to it, with prepending "%cpaste" and appending "--" This is what I came up with function! ...
user avatar
  • 131
1 vote
1 answer
27 views

I wish <C-h> deletes characters that were inserted before pressing the ESC button

In the insert mode after pressing some characters the <C-h> combination pressed once removes the character to the left of the cursor. When repeated it removes next left character and so on. But ...
user avatar
  • 113
1 vote
1 answer
60 views

How do I yank the next 4000 chars, ignoring linebreaks?

I can for example, copy three lines to the clipboard with "+y3j. But I nothing happens when I attempt to yank chars to the clipboard with, say,"+y100l. Ultimately, I want to copy chunks of ...
user avatar
  • 211
0 votes
1 answer
76 views

quickly replace content between quote, bracket ?

“hello world” “need be replaced by hello world” What I do is put cursor in first line, issue command yi" and then move cursor to second line, issue vi"p I want to know is there any more ...
user avatar
  • 101
2 votes
1 answer
62 views

Option to prevent outer yank (ya') from yanking leading whitespace?

If i have something like foo( 'parameter' ) and I press ya' with the cursor somewhere inside the parameter string then the indentation space gets yanked too and I end up with 'parameter' in my * ...
user avatar
  • 137
2 votes
1 answer
111 views

Restoring cursor to position before delete after Undo

This question is asked multiple places but none have an answer that works for me. I've tried: '' `` g; g, ; , Ctrl+o In a file add: 123456789 Move your cursor over 7 in normal mode, type d4h, press u....
user avatar
  • 133
0 votes
1 answer
35 views

Delete multiple lines from cursor upwards

If you have a text like: word1 word2 word3 word4 word5 You can put your cursor over first d, type 2D and be left with: wor But you can't do the deletion upwards from second line with 2d^ or 2d0. ...
user avatar
  • 133
0 votes
1 answer
492 views

vim ctrl+c doesn't copy/paste with ctrl+c or ctrl+v

I was trying to map ctrl+c to copy, ctrl+v to paste in vim, but it's not working properly.I've tried https://stackoverflow.com/questions/61177658/mapping-select-all-copy-paste-in-vim and https://...
user avatar
3 votes
1 answer
116 views

Paste a column in a table

Suppose I have this file open in Vim: AXXK M(X) 1.1 1 1.2 8 And that the clipboard holds U(1X) MX1 MX2 How can I easily paste that content as a new column? I want: AXXK M(X) U(1X) 1.1 1 ...
user avatar
  • 2,143
1 vote
2 answers
101 views

Vim - Yanking a set/number/block of lines, and inserting/appending them before/after another set/number/block of lines?

If I have two 'sets' of lines, each consisting of X number of lines (but the lines differing in their individual lengths), can I yank one set and insert (or append) it to the other? To illustrate, can ...
user avatar
  • 163
0 votes
1 answer
58 views

Automatically save deleted lines to a new file?

I have a to do list that I manage in vim. I want to keep track of things I remove from the list. After I type dd to delete a line, I want to write this line to a different file. I only want this ...
user avatar
2 votes
3 answers
62 views

How to delete a range of lines not up to N lines under a lines matching a pattern?

Say I have a document cat dog xxx 1 2 3 cow xxx a b c horse I would like to be able to run a command that will end up with xxx 1 2 3 xxx a b c whereby the transformation is defined by matching all ...
user avatar
0 votes
1 answer
34 views

How to multicut, edit and paste word after a word [duplicate]

Want to find a way to do in vim what I usually do in other text editors. It's really hard to describe the problem, so I've created a gif and attached it to this question. Initial document state: inv/...
user avatar
0 votes
0 answers
23 views

Creating vimrc kills my plugin

I have the following ~/.vim/filetype.vim: augroup filetypedetect au BufRead,BufNewFile *?Script.sml let maplocalleader = "h" | source /home/gergely/HOL/tools/vim/hol.vim " recognise ...
user avatar
  • 221
2 votes
0 answers
72 views

While copying a file in netrw, why should I be in the directory where the file is located?

In netrw, I want to copy a file /dir/subdir1/file.txt to /dir/subdir2. For that, I do the following: I mark the file /dir/subdir1/file.txt I navigate up directory and mark /dir/subdir2/ as target ...
user avatar
0 votes
2 answers
40 views

How to cut characters in the middle of a line and place later in the line (not at the end)

This top line shows how it needs to be formatted, and the other 3 lines show how it currently is formatted. I need the bottom three lines to look like the top line. So, I need to essentially cut this ...
user avatar
2 votes
2 answers
347 views

What is the fastest way to yank with a line break? [duplicate]

Let say I have a simple line hell<cursor>o What is the fastest way to yank this line and paste to a result like this? hello hello I am currently doing this: yy # To yank this line p # Paste ...
user avatar
0 votes
2 answers
54 views

How can I warn when a large chunk of data is about to be (unknowingly) deleted?

I would like a warning when a large chunk of data is to be deleted. I tend to use the mouse along with vim to highlight text (to copy or delete). I also use the mouse to scroll notes when I want to ...
user avatar
  • 1
0 votes
1 answer
29 views

Waiting for a copy event

I have the following function: function _X() normal! gvy vs tmp normal!p ALEFix black normal! ggVG normal! y <------- endfunc Unfortunately, the y does not work. That is, ...
user avatar
  • 1,767
0 votes
2 answers
76 views

Yanking range into register while ignoring blank lines

I’m trying to yank a range into a register while ignoring blank lines. My range is from line 10 to the end of the file. :10,$v/./"*y Looking at my registers in :reg I see that my text is not in ...
user avatar
0 votes
2 answers
91 views

Efficient ways of moving/swapping words?

In my current flow, I find that moving words is made slower by having to insert a whitespace, so I was wondering if there is a more efficient way Here are two use cases: how do I efficiently move a ...
user avatar
0 votes
1 answer
80 views

What is a quick and efficient way to cut and paste text with Vim?

I'm a new Vim user (using the Vim extension in VSCode), and while it's faster at some operations, I'm having a lot of trouble finding an easy way to cut text (copy and delete it), then paste it at ...
user avatar
1 vote
2 answers
155 views

Copy to clipboard or save to file substitution command

I'm trying to answer a vim question in U&L, which involves a very complex and long regex substitution. I would like to copy to clipboard the command, or save it in a file, so I don't have to make ...
user avatar
7 votes
2 answers
387 views

Deleting lines matching a pattern and put them into the buffer

I am trying to do this: deleting lines matching a pattern and then copy these lines into some other place in the file. :g/PATTERN/d does delete the lines but when I use p or P, only the last line is ...
user avatar
  • 221
1 vote
1 answer
56 views

Copy lines and execute in terminal window

Edit a python file with vim adddf.py, and type vert term and python3, there are two windows in vim. cat adddf.py def add_df(df,number): import re new_df = pd.DataFrame() nrow = df.shape[0] ...
user avatar
  • 820
-1 votes
1 answer
40 views

mapping to delete and yank multiple lines e.g. d4y instead of d4d

In my vimrc I have nnoremap d "_d nnoremap yd dd to not save lines when I delete. Is it possible to create a mapping that when I press e.g. d4y it will cut 4 lines and save them into buffers? I ...
user avatar
  • 119
3 votes
2 answers
286 views

Is it possible to copy/yank everything until a matching word is found?

Say I have a text like ... def my_function() do ... end ... And I want to yank/copy from def to end (including both def and end), so I can paste this block of text elsewhere. Is it possible to that ...
user avatar
0 votes
1 answer
26 views

How to copy the current value of a `set` option into the clipboard?

I sometimes need to copy the current value of a set option, e.g. set statusline, into the clipboard (+) to paste its value here. I know how to show the current value of a set option, e.g. set ...
user avatar
  • 995
3 votes
1 answer
276 views

Recover cut text in vim

I've changed 2 pieces of text accidentally, by using C. Is it possible to access the previous piece, not the last one? (after getting out of vim) If I log back in, by pressing p it prints the last ...
user avatar
  • 153
0 votes
0 answers
126 views

Copy text from terminal and paste to Vim while preserving text color

Is there a way to copy colored text from terminal and paste it as colored into vim? I am on MacOS, using iTerm2 Build 3.4.4beta3, and the following Vim version: % vim --version VIM - Vi IMproved 8.2 (...
user avatar
  • 101
0 votes
1 answer
39 views

Yanking into register within a script is not working

Given a file like this: Roy Maurice Jen Douglas If I were to type the following commands: ggVj"zy, followed by :reg z, I would see Roy and Maurice. Now I want to yank Jen and Douglas into the z ...
user avatar
  • 326
0 votes
0 answers
38 views

How do you disable automatically copying text when pasting over it in visual mode in VS Code? [duplicate]

Like the title says, if I have yanked some text, then select what I want to replace in visual mode, press p to paste, I want the original text still available to paste in other locations. I never ...
user avatar
  • 101
0 votes
0 answers
50 views

How to bind <C-U> to <Cmd><BS> in vimrc?

I understand that <C-W> is backward-kill-word and I have bound this to shiftBS and it works. But now I want to bind <C-U> to cmdBS. Is this possible? If so, how can I do this?
user avatar
  • 731
0 votes
1 answer
551 views

How to copy text to clipboard in visual mode? [duplicate]

I ran the following sequence of commands: V10j ⌘ c but it seems like this doesn't copy the ten lines to my clipboard. So how can I do this?
user avatar
  • 731

1
2 3 4 5
8