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
2 answers
101 views

Copy content inside brackets and the word in front of bracket (i.e. a text object for function calls)

Quite often I copy or remove content inside brackets d% or y%. MyAwesomeClass( ///content ) But this way I get: ( ///content ) Is there a way to copy word in front of the bracket too? So that ...
  • 139
0 votes
0 answers
20 views

Yank paste not working after trying to map clipboard to register

I tried making clipboard work with yank paste. And now for some reason normal V+y and p doesn't work as intended anymore. for example: { pb.push(to_string(pb.top()).size()); pb.pop(); } ...
0 votes
1 answer
37 views

On Windows, putting lines with P results in the * register at the end of current line instead of the " register and shifting the current line down

I use the same configuration on Windows as I do on Linux. It works normally on Linux but on Windows (vim and gvim) I am getting this odd behavior when putting lines with P: Steps: I yank a line with ...
  • 139
3 votes
1 answer
42 views

Paste command to command mode instead of insert mode

I observed a difference in behavior between Vim and Neovim: When pasting a :-prefixed command in normal mode, Vim will enter command mode whereas Neovim will enter insert mode. More precisely: Given ...
  • 187
1 vote
3 answers
57 views

How to replace line with the yanked one multiple time?

In many cases, I have to replace a line by another in multiple places. I can yank my desired line, go do the replacement location, do a pdd, move on, and of course I don't have the same line available ...
  • 187
0 votes
0 answers
30 views

Pasting via vim doesn't paste whole text and gets stuck in the insert paste mode

For a while now, I've been dealing with a problem where when pasting a large amount of text, such as the code in this gist, into a file via vim, only part of the copied text gets pasted, then stops ...
0 votes
2 answers
64 views

How can I select all non-lowercase multiline blocks which follow a keyword

I'd like to copy these to a file, but in a speculative future case, I might want to delete them. I might need to find a regex to substitute intervening data with a single blank line. The highlighting ...
  • 1
25 votes
4 answers
4k views

How can I send just-yanked text to the clipboard?

If I've already yanked 37 lines, is there a way to send them to the clipboard without having to select them again? I need to move those yanked lines into a GUI application.
1 vote
3 answers
258 views

How to copy between two '##'

In vim, there is a way to yank between two quotations by using yi'. And there is a way to yank between two square brackets by using yi]. I want to do this between two ##: some_text ## Point #1 --> ...
0 votes
1 answer
28 views

somehow paste to random location ... tell vim to always ignore any roller actions from mouse middle roller button

I have been using vi or vim for many years however recently ( past year or two ) when I paste some highlighted text vim seems to paste highlighted text ( more often than not ) to random location in ...
0 votes
3 answers
103 views

vim copy/paste from clipboard while keeping indentation

I am using Putty on Windows to connect to a Linux server. On the Linux server I am using vim to edit code files. I am using my mouse to select an area to copy and then right click to paste the copied ...
0 votes
0 answers
40 views

How do I yank to a custom clipboard, but put normally?

Whenever I yank (y) in vim, I'd like to trigger a custom clipboard script. This works fine. However, I also want the put (p) functionality to continue working as normally, ie. pasting from the normal ...
  • 101
0 votes
1 answer
92 views

How to replace text with clipboard content in VsCode using VsCodeVim?

I am using vscode + vim. Consider a common scenario where I have to yank/delete some text from one place and replace it with some text anywhere else. But as I need to replace I have to first delete ...
0 votes
1 answer
34 views

What happens when giving a backwards range (to yank) in Vim?

If you have: minimum working exampl[e] with [] representing your cursor, and issue :.,-2y, Vim will tell you "Backwards range given" and prompt you to swap. If you don't swap it seems to ...
2 votes
0 answers
33 views

Store the current filename in a given register

When I exchange with colleagues about the code, when I refer to given functions, I like to also mention the file. Since this exchange does not usually take place within vim, I usually copy them out ...
2 votes
3 answers
55 views

How to remember and recall cursor position?

Imaging I'm editing some code, and I found a few words that I would like to paste at the current cursor position elsewhere in the file. I will go to them, yank them, but then how do I return back to ...
5 votes
1 answer
60 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?
0 votes
1 answer
23 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 = ...
  • 1,164
1 vote
1 answer
37 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 ...
  • 395
0 votes
0 answers
37 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: ...
0 votes
1 answer
56 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, ...
  • 147
3 votes
1 answer
100 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> ...
1 vote
2 answers
132 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,...
1 vote
0 answers
31 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 ...
  • 111
0 votes
1 answer
206 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 ...
  • 103
0 votes
0 answers
29 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 <...
3 votes
1 answer
90 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 ...
  • 145
0 votes
0 answers
61 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 ...
  • 165
0 votes
2 answers
101 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 --...
-1 votes
1 answer
99 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 ...
2 votes
1 answer
148 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 ...
2 votes
1 answer
150 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 ...
  • 121
3 votes
0 answers
74 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! ...
  • 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 ...
  • 113
1 vote
1 answer
62 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 ...
  • 211
0 votes
1 answer
123 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 ...
  • 101
2 votes
1 answer
65 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 * ...
  • 137
3 votes
1 answer
189 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....
  • 143
0 votes
1 answer
37 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. ...
  • 143
0 votes
1 answer
726 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://...
3 votes
1 answer
172 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 ...
  • 2,297
1 vote
2 answers
156 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 ...
  • 193
0 votes
1 answer
79 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 ...
2 votes
3 answers
64 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 ...
0 votes
1 answer
35 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/...
0 votes
0 answers
27 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 ...
  • 221
2 votes
0 answers
82 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 ...
0 votes
2 answers
43 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 ...
2 votes
2 answers
384 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 ...
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 ...
  • 1

1
2 3 4 5
8