Skip to main content
Share Your Experience: Take the 2024 Developer 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
0 votes
0 answers
29 views

Paste in front or after in column mode?

I can enter column mode by <C-v> , moving down a couple of rows by pressing several times j, then paste some content from the registry via pressing p or P. However, the pasting will replacing ...
athos's user avatar
  • 195
-1 votes
1 answer
23 views

Smart yank+paste function arguments

I find myself sometimes having to rearrange arguments to functions in C-like languages. I.e. changing: hello("world", makeExclamation(1), foo(bar(a, b, c))) -> hello(foo(bar(a, b, c)), &...
bitmask's user avatar
  • 143
0 votes
0 answers
39 views

Copy text from remote headless Neovim server using local Neovim --remote-ui

I have a docker container running nvim --headless --listen 0:0:0:0:7777 I can connect to it successfully with nvim --remote-ui --server localhost:7777 There does not seem to be any built in copy ...
Jeff Bigler's user avatar
0 votes
3 answers
50 views

Paste in visual block mode

I would like to copy some text at the beginning of several lines. What I have is: line 111 222 333 444 And what I want is: line line 111 line 222 line 333 line 444 I know that I can add line at ...
jeirual's user avatar
0 votes
1 answer
28 views

Yank across multiple lines with single line breaks

I can use the following to yank text inside of quotes across multiple lines, separate that text by a single new line, and be able to paste it characterwise. let @q = '' | *g/^/exe 'norm! "Qyi&...
Rob Mosher's user avatar
1 vote
4 answers
37 views

Rotate list of lines

Assume you have the following block of text (yes: I am using vim-latex, but this is not relevant): \begin{itemize} \item 1 % [[[ \item 2 \item 3 \item 4 \item 5 % ]]] \item 6 \end{itemize} My ...
brad's user avatar
  • 131
1 vote
2 answers
94 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
81 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
33 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
398 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
  • 677
1 vote
3 answers
63 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
31 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
50 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
197 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
322 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
203 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
4 votes
0 answers
307 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
  • 141
1 vote
1 answer
82 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
192 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
242 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
864 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
1k 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
27 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
171 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
224 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
186 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
  • 464
0 votes
2 answers
167 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
3k 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
248 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
176 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
3 votes
3 answers
3k 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
  • 41
1 vote
1 answer
73 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
115 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
138 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
110 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
980 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
49 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,333
1 vote
5 answers
502 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,333
0 votes
2 answers
111 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,140
3 votes
1 answer
444 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
91 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
69 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
236 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
762 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
567 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
47 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
  • 479
0 votes
2 answers
50 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
76 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
2 3 4 5
10