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

Yank current line range

I would like to yank the current selected line range (not the line range content). For example, if my selection goes from line 51 to 67, I looking for a way to yank 51,67 to my default register.
Martin Delille's user avatar
0 votes
4 answers
76 views

How to paste Vim (normal mode) commands?

I need to copy a sequence of (normal mode) commands and then paste it to be executed in Vim. When I try that now though it inserts it for me into the document. How can I paste sequence of Vim (normal ...
Helmut M's user avatar
1 vote
0 answers
20 views

Pasting into vim over ssh repeats or drops 6 characters at random

When I SSH into a remote Ubuntu container on a particular system and open vim, I cannot paste consistently. Say I copy the string abcdefghijklmnopqrstuvwxyz to my clipboard. If I open vim, enter ...
James Hochadel's user avatar
4 votes
1 answer
392 views

Why does `yW` yank until the end of the WORD, but `W` move to the next one?

My confusion started with realizing, that yW yanks a different region, then what vW selects, but I found this that explains about selection. But then I realized, that while yW will yank until the end ...
fbence's user avatar
  • 667
1 vote
3 answers
59 views

Block select unequal lines

I often have code of the form: money = double(123) user_level = user["level"] timer = get_time() and want to have: money = double(123) user_level = user["level"...
FromTheStackAndBack's user avatar
0 votes
2 answers
29 views

Retain externally copied text when yanking

I've got clipboard=unnamed which means that when I copy from somewhere outside Vim, I can just "put" it into Vim without any additional thought. Most is the time this is perfectly adequate. ...
LondonRob's user avatar
0 votes
0 answers
38 views

Behavior of copy/paste with system register + has suddenly changed

(Vim version and system info follows at bottom) Never had any problems copying to the system register with "+y before, nor pasting from that register into another application or into a terminal. ...
Newlin's user avatar
  • 11
0 votes
3 answers
151 views

Why Y doesn't work like `yy`, but works like `y$`?

Why Y command doesn't work like yy, but works like y$? I mean, everyone says that it does work like yy, but for me, it doesn't. So how do I fix it? For the close reason: This question doesn't help me. ...
Fmbalbuena's user avatar
1 vote
3 answers
318 views

How to print yanked data in replace mode?

I want to paste data from clipboard. But instead of insert the data, I want to overwrite (like using R).
Andy A.'s user avatar
  • 233
1 vote
1 answer
200 views

What does the little character 'a' (`ª`) mean when pasting text?

I'm very new to Vim. I use Vim in PowerShell on Windows 11. On normal mode I press p to paste a text, but instead only this character ª shows up. What does this mean? Typing "*p: or :reg " ...
Ooker's user avatar
  • 113
3 votes
0 answers
198 views

How to copy to system clipboard using Mosh + Tmux?

I've set vim.opt.clipboard = "unnamedplus" to copy to/paste from the system clipboard. However, I noticed that the behavior differs whether I'm using nvim in my local machine, a remote ...
Gianluca's user avatar
  • 131
1 vote
1 answer
72 views

Vim has Erroneous Behavior on paste?

This honestly might be a bug. But sometimes when I am pasting into vim (on insert mode, using CMD+V), it just pastes some partial output of what I had copied and does extra things like deleting ...
profPlum's user avatar
  • 113
0 votes
1 answer
149 views

Paste from WSL to gVim running under WSL add carriage return (CR / ^M) to the end of all pasted lines

Using WSL2/WSLg and Ubuntu 22.04 LTS under it, with gVim running and has a Linux file opened (i.e. with LF endings only), when I paste text from Windows into gVim, all the lines pasted have the CR/^M ...
Hans Deragon's user avatar
1 vote
3 answers
179 views

Exclude empty lines when copying

I'm writing Python programs using Vim/NeoVim. One thing I often do is copying text to the system clipboard using "+y command. This lets me copy parts of the program to the clipboard, and run it ...
RogUE's user avatar
  • 111
0 votes
1 answer
643 views

Pasting from system clipboard adds an unwanted new line

On windows, using neovim, with clipboard=unnamedplus , when I paste from the system clipboard using p or :put , it will always paste in a newline , even if the content of the clipboard has no newline. ...
icesentry's user avatar
1 vote
1 answer
711 views

What's the difference between d, and x?

What's the difference between d and x? As per my cheatsheet, the definition says x Delete characters after cursor d Cut but remain in normal mode I dont know because i'm new to vim
someuser's user avatar
0 votes
0 answers
25 views

Why does <esc> on empty, indented line, jump to beginning?

I'm trying to do something very simple, enter normal mode and ALWAYS be able to somehow put the normal mode cursor where it was in insert mode, whether through a mark, or otherwise. I'm doing this ...
Tallboy's user avatar
  • 177
2 votes
2 answers
167 views

How to replace till the end of the line without joining lines?

One of the main usage I have for selection is replacement. Suppose I have: Jane: Hello foo1 & bar1 John: Hello Jane: Hello foo2 and bar2 John: Hello Jane: Hello foo3 or bar3 John: Hello That I ...
Vivian De Smedt's user avatar
3 votes
2 answers
214 views

Vim yank from cursor position to end of nth line

I am trying to yank from my cursor posintion to end of nth line defined by a motion. So for the below text Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec non quam et erat pharetra ...
gmtek's user avatar
  • 145
0 votes
3 answers
155 views

Paste in visual block mode without deleting the character under vertically multiple cursor

When I want to paste some text after selecting vertically with <C-q> It is known that Vim/gVim will replace the character under the cursor. For example, below is shown the result after pasting ...
xyx's user avatar
  • 422
0 votes
2 answers
132 views

Is there a way in Vim to paste a line so it pushes the current line down?

The default pasting behavior in vim is to put the line directly below the cursor. Pasting "Line 2" on "Line 1" results like this: Line 1 Line 2 Line 1 Line 2 Is it possible to ...
user avatar
10 votes
4 answers
2k views

How can I delete in Vim all text from current cursor position to the end of file without using End key?

Is there any other possibility to delete from the current cursor position till end of the file without using the End keyboard key? I know that I can perform it with d<CTRL-End> but perhaps is ...
Rob Bar's user avatar
  • 123
0 votes
0 answers
220 views

Copy to android system clipboard in nvim from termux

I use Neovim on termux on android 11 I commonly use :y to yank/copy text to nvim clipboard Then paste it to another files Recently I've tried using helix-editor(hx) looks and feels so similar to ...
ANDuser's user avatar
0 votes
0 answers
152 views

How to use `Ctrl+c` in Nvim if GNOME terminal SIGINT call was remapped to Ctrl+x?

GNOME terminal SIGINT call was remapped to ctrl+x using stty intr ^X, and ctrl+c was mapped to be 'copy'. In Neovim config I have vim.keymap.set("v", "<C-c>", "\"+y&...
Vlad Mosienko's user avatar
0 votes
2 answers
2k views

NeoVim: Following the instructions in ":h clipboard-wsl" not work? It shows "no provider" but also "ok" in ":checkhealth"?

I am using neovim on archlinux/WSL2, and try to communicate with the Windows clipboard in neovim. Following the instructions in :h clipboard-wsl, I filled in init.lua with code: vim.g.clipboard = { ...
Jerry Z's user avatar
  • 11
1 vote
1 answer
69 views

How to yank while in visual mode without showing message?

When I'm in visual mode and I yank the selection (which has at least 3 lines), messages like these are shown: 4 lines yanked block of 4 lines yanked How can I suppress this so it won't appear in :...
Steve Ward's user avatar
0 votes
0 answers
98 views

How to search for yanked text in a macro?

How do I search for yanked text in a macro properly? I tried the following: qq (start a macro) yi" (yank text inbetween ", let's say the yanked text is foo) / press ctrl + r " (I ...
Sebastian Nielsen's user avatar
1 vote
0 answers
96 views

How to override neovim paste implementation?

I wanted to add some handler that is triggered whenever a paste happened. From what I know, there is no such a thing like autocmd for paste action. I have look into some possible solution such as ...
Muhammad Sulthan Mazaya's user avatar
1 vote
1 answer
83 views

Syncing x clipboard with yanks and put only?

I have discovered the joy of having :set clipboard^=unnamedplus. One issue I often face however is having whatever was last copied or yanked be overwritten by what I just deleted. I don't think ...
dvqc's user avatar
  • 13
4 votes
2 answers
745 views

Replacing text with a visual block

Here is what I want to do. Consider the text abcvvxyz abcvvxyz 123456 123456 I would like to copy the v block and paste it over the 45 block to get the following: abcvvxyz abcvvxyz 123vv6 123vv6 ...
January's user avatar
  • 263
0 votes
0 answers
41 views

What's controlling Vim paste behaviour?

What's controlling Vim paste behaviour via Vim over ssh using putty with right-click paste set to Linux host? To start we have: VIM - Vi IMproved 9.0 (2022 Jun 28, compiled Mar 27 2023 00:00:00) ...
chipfall's user avatar
  • 103
3 votes
1 answer
452 views

How to yank without a buffer?

Does any kind of :call yank(register_name, "string") API exist in vim? Or at least :yank register_name "strings" - I can't find any way to yank in vimscript without modifying a VIM ...
minseong's user avatar
  • 2,291
1 vote
5 answers
407 views

Yank lines without leading whitespace

If I have code like this: const treeData = { name: "Parent", children: [ { name: "Child 1", children: [ { name: "Grandchild 1" ...
minseong's user avatar
  • 2,291
0 votes
2 answers
96 views

How can copy the matched string into register +?

For the below data: -150000 2023-03-30 421.67 2023-04-20 575 2023-05-20 I can substitute the whole line with the first string :%s/\v.{-1,}\s+(.+)/\1 Then the content was changed into: -...
showkey's user avatar
  • 1,120
3 votes
1 answer
402 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 ...
Guilherme Marthe's user avatar
0 votes
2 answers
85 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?
user2741831's user avatar
1 vote
2 answers
85 views

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

In init.vim I have the following setting to ensure the text is yanked to the system clipboard: set clipboard^=unnamed,unnamedplus In Neovim, I select the lines with visual line mode (V) and copy them ...
Wenfang Du's user avatar
0 votes
1 answer
61 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 ...
Puya's user avatar
  • 15
1 vote
2 answers
196 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 ...
qotsa42's user avatar
  • 21
1 vote
1 answer
633 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 ...
xaxa's user avatar
  • 177
0 votes
1 answer
408 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 ...
Pen pal's user avatar
0 votes
1 answer
46 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 | ...
Bog's user avatar
  • 457
0 votes
2 answers
49 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, ...
cesces's user avatar
  • 25
1 vote
2 answers
68 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&...
xoux's user avatar
  • 125
1 vote
1 answer
33 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 ...
Zantier's user avatar
  • 111
0 votes
1 answer
61 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 ...
Rob Bednark's user avatar
1 vote
1 answer
133 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 ...
user202729's user avatar
0 votes
1 answer
90 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 ...
rturrado's user avatar
  • 103
0 votes
1 answer
304 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 ...
Jon Deaton's user avatar
0 votes
1 answer
131 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 ...
Peter Petigru's user avatar

1
2 3 4 5
9