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
1 answer
193 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
1 vote
0 answers
68 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
  • 111
1 vote
1 answer
66 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
72 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
122 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
302 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
368 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
23 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
159 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
201 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
105 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
  • 388
0 votes
2 answers
105 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
167 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
102 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
1k 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
63 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
68 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
68 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
63 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
589 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
34 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
450 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 ...
theonlygusti's user avatar
  • 2,219
1 vote
5 answers
295 views

Yank lines without leading whitespace

If I have code like this: const treeData = { name: "Parent", children: [ { name: "Child 1", children: [ { name: "Grandchild 1" ...
theonlygusti's user avatar
  • 2,219
0 votes
2 answers
82 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,104
3 votes
1 answer
370 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
84 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
0 votes
2 answers
72 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
58 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
139 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
503 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
  • 165
0 votes
1 answer
234 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
36 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 | ...
Pixelbog's user avatar
  • 417
0 votes
2 answers
46 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
61 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&...
evianpring's user avatar
1 vote
1 answer
31 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
54 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
117 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
58 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
245 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
102 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
0 votes
2 answers
2k 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?
kraber's user avatar
  • 1
8 votes
1 answer
484 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?
Vinn's user avatar
  • 627
0 votes
1 answer
88 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?
VanillaDonuts's user avatar
1 vote
2 answers
1k views

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

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 ...
Madoka's user avatar
  • 63
1 vote
0 answers
91 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 -...
newview's user avatar
  • 291
0 votes
2 answers
40 views

Copy text from all folds, excluding titles

How do I copy all lines from all folds, excluding the fold titles?
markling's user avatar
  • 319
3 votes
1 answer
247 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 ...
zoomlogo's user avatar
  • 218
2 votes
3 answers
266 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 ) ?
Spencer Maroukis's user avatar
0 votes
1 answer
116 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 ...
Barzi2001's user avatar
  • 481

1
2 3 4 5
9