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

How to clear the uppercase registers?

The uppercase register has this nice characteristic of allowing appends to them. However, every time I use them to yank a series of text, when it's time to paste them, I can see the old text from when ...
0 votes
2 answers
65 views

How can I copy the whole number under the cursor?

Lets say I have a list like this: marcus1235lt jonas3456lt ^Cursor is here thomas345pt how can I yank the number under the cursor, in this case 3456, without getting any characters?
0 votes
1 answer
17 views

`Cmd+V`/`Ctrl+V` pasting has an extra new line

In init.vim I have: set clipboard^=unnamed,unnamedplus In order to ensure text is yanked into the system clipboard. In Neovim, I select the lines in line mode (V) and copy them with y: a b c In a ...
-1 votes
1 answer
31 views

Copying non-consecutive selected lines in visual mode

Basically I want to select and copy a bunch of non-sequential lines (some lines only partially) from different locations of a code, in a way that each yanked line is appended to clipboard register so ...
  • 1
0 votes
2 answers
50 views

Yank non-consecutive lines into the register?

I'm surprised this hasn't been asked yet, but how do I copy non-consecutive lines into the buffer at once? For example, let's say my file looks like this: 1 2 3 4 5 6 7 8 9 10 What commands can I use ...
  • 11
1 vote
1 answer
166 views

Always duplicate yanked text to system clipboard

I'm using neovim 0.8.2 Is there a way to automatically mirror last yanked text to system clipboard, regardless of which register I used to yank it to? So if I run something like "ayiw I will have ...
  • 165
0 votes
1 answer
25 views

How to yank a word with its surrounded quotes?

Is there an easy vim keyboard shortcut to yank a word, including its surrounding quotes? For instance I would like to yank 'my_word' from the statement below: tmp = my_func(arg1, 'my_word') How can I ...
0 votes
1 answer
26 views

How to paste below, not to the right nor to the left

Question I think you see the problem... How can I paste directly below? Is there a way? Setup I have this table and I want to copy/yank the 3 × | in visual block mode and then paste it: | sign | ...
  • 172
0 votes
2 answers
41 views

Report more than 200 lines cut/pasted -- Vividly?

I have a text document where I frequently move/cut large blocks of text. Every 2-3 months I inadvertently cut or paste a huge number of lines (60,000 today) and discover the error hours, or even days, ...
  • 25
0 votes
2 answers
26 views

What are the different behaviors of `daw` and is there a difference between a `word` and a `WORD` (based on docs)?

Consider the sentence The sky is very blue today. Let's investigate what happens when we use the vim command daw with the cursor placed at different positions. Cursor at any character of "blue&...
1 vote
1 answer
20 views

Why doesn't the dot command work after pasting in visual mode?

1. Why doesn't this work? If my text file is: aaa test bbbb test test bbbb test test bbbb test I can yank aaa, select bbbb in visual mode, and type "0p, to replace it with aaa, with the idea of ...
  • 111
0 votes
1 answer
28 views

How do I use variables with the delete command? (i.e., how to expand/reference variables for command arguments?)

I'm using variables for line numbers, and I want to delete a range of lines using these variables. How do I do that? let x = 5 let y = 20 " I want to delete the range of lines from x ...
1 vote
1 answer
70 views

How can I create a keybinding that pastes in the terminal in bracketed paste mode, but only if the shell supports it?

Xterm has a feature where if you put in .Xresources XTerm.vt100.translations: #override \ Shift Ctrl<Key>V: insert-selection(CLIPBOARD) then ctrl+shift+V will paste from clipboard. I notice ...
0 votes
1 answer
24 views

How to repeatedly yank whole buffer without losing the yanked contents

I select the whole contents of a source buffer: ggVGy. Then I move to another buffer, let's say D1. I update the the whole contents of the destination buffer with the yanked text: ggVGp. Now, if I ...
  • 103
0 votes
1 answer
104 views

Neovim saving yanked text to file with TextYankPost

I'm trying to write some functionality in neovim to make it possible to yank + paste between neovim instances. The approach is to intercept yanked text and write it to a temporary file, then remap ...
0 votes
1 answer
48 views

Vim mapping: Copy whole line X lines up/down and paste it X lines down/up

I find myself doing the following very often: xkyyxjp (where x is a number). I copy a whole line x lines up, and then I paste it x lines down (and vice versa); and so I wanted to make a map so I can ...
0 votes
2 answers
95 views

How to select all text and delete in vi?

Is it possible to select all the text and delete it it in vi other than hitting backspace?
  • 1
8 votes
1 answer
447 views

ci) - also delete the surrounding parens?

I use ci) and ci] quite a lot to change what happens in between the parens or brackets. Is there a way to remove everything including the parens or brackets?
0 votes
1 answer
37 views

How to yank from EOL, including the last character?

In normal mode, I want to set a mark (ma) and then yank until the end of the line, including the last character ($ and y`a). But $ doesn't include the last character. What is the solution?
0 votes
2 answers
193 views

How to stop (neo)vim from yanking text on pasting over selection?

I want to make Neovim stop yanking the text I paste over into my register (mapped to system clipboard with vim.opt.clipboard = 'unnamedplus'), eg If I have the text: asdfghjkl asdfghjkl asdfghjkl and ...
  • 13
1 vote
0 answers
30 views

The most lazy way to call the vim-copied content into bash

Setting in my .vimrc: set clipboard=unnamedplus Supporting in my vim: vim --version | grep clipboard +clipboard +jumplist +popupwin +user_commands +ex_extra -...
  • 283
0 votes
2 answers
26 views

Copy text from all folds, excluding titles

How do I copy all lines from all folds, excluding the fold titles?
  • 309
3 votes
1 answer
78 views

How to delete till a specific word?

I have a bunch of text, say: This is some sample text. I would like to delete this text. The question is how do I delete till a specific word. If my cursor is at the start of the above sentence, and ...
  • 198
2 votes
3 answers
219 views

How to cut a markdown link on the same line e.g. from `[` to `)`?

If I'm anywhere on a line that contains e.g.: [text1](link to text1) How do I cut from [ to ) ?
0 votes
1 answer
37 views

Yank list of lines into a register in vimscript

I am writing a function and I wish to yank a range of lines into a register. The line that I cannot fix is the following: let @" = getline(l:line_in,l:line_out) where l:line_in and l:line out ...
  • 225
2 votes
2 answers
230 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 ...
  • 141
0 votes
0 answers
30 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
41 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 ...
  • 229
3 votes
1 answer
334 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
110 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
76 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
3 answers
91 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
280 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
41 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
125 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
172 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
2 answers
375 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
69 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
36 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
67 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
68 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
53 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,354
2 votes
1 answer
74 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 ...
  • 465
0 votes
2 answers
104 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. I still get the same error when I'm logging in via ...
0 votes
1 answer
114 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, ...
3 votes
1 answer
156 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> ...
2 votes
2 answers
411 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
68 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
3 votes
1 answer
505 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 options for cut, copy and paste. How can I get this type of ...
  • 133

1
2 3 4 5
9