All Questions
Tagged with paste or cut-copy-paste
494 questions
36
votes
4
answers
12k
views
Delete from cursor till nth occurence of character x
I know that I can delete from the cursor till and including the first occurence of a character x with d/x<CR> or with v/x<CR>d if I want to see the selection first and then delete. How can ...
0
votes
2
answers
52
views
Copy text from all folds, excluding titles
How do I copy all lines from all folds, excluding the fold titles?
0
votes
0
answers
22
views
Paste clipboard linewise if it has new lines, or characterwise if it does not
I would like to remap all paste commands to take these special actions before pasting the system clipboard "+ register:
if the register is not "+, paste according to default behaviour
...
2
votes
2
answers
725
views
Can I yank from the current position of the cursor to the end of the line without the newline?
I've got a list of files that I want to copy from one place to another, I need to change the name slightly and I'd rather copy the file names instead of typing them over and over again.
If I do YP I ...
0
votes
0
answers
35
views
Errors when copying and pasting text using gVim under Windows 11
I have a reoccurring problem when using Ctrl c and Ctrl v between two files opened in gVim Version 9.1.
When I copy a portion of text from file 1 and then paste it in file 2 I get various "extra&...
0
votes
2
answers
459
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 ...
10
votes
6
answers
4k
views
Clipboard is reset after first paste in Visual mode
When I make a selection in Visual mode and copy, then select a text and then paste, this paste only works once. For the next time, I again have to go to the original source and then do the copy ...
0
votes
1
answer
32
views
How to I paste the word I copied before deleting something?
I am a new Vim motions user, I use it in VsCode. The most annoying thing that I run into constantly is that when I try the following:
const animal = "dog";
const pet = "cat";
I ...
1
vote
1
answer
85
views
Problems using Vim to yank to clipboard
I can't seem to yank to clipboard within Vim on Ubuntu (Windows Subsystem for Linux). I am pressing "+y and it's giving me the regular X lines yanked, instead of X lines yanked into "+ to ...
7
votes
2
answers
835
views
How to exit insert mode if pressing escape merely types "^["?
I have neovim 0.4.2 running in a session of kiTTY 0.17.4 on OSX. I have pasted a long url while in insert mode.
After doing this, every time I type BKSPC vim adds ^? to my document. Every time I type ...
0
votes
3
answers
1k
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
1
answer
74
views
Vim visual block copy don't paste in KDE konsole
Selecting by visual line mode and copying (V and y) in vim in rxvt-unicode or in gnome-terminal and pasting in another tab of that terminal with Shift + Insert works well.
But trying to do the same ...
0
votes
1
answer
504
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 ...
1
vote
1
answer
37
views
Vim suddenly "forgets" whether yanked text was character-wise or line-wise
I have a habit of copying lines of text across files by yanking it, closing Vim, starting Vim with the target file, then p. However, earlier today Vim started to forget that I yanked whole lines of ...
24
votes
3
answers
26k
views
How do I copy a file in netrw?
The current working directory is ./A/B/. An empty document is opened when I type vim, and the netrw is opened with command :e. The window is split by vs., and I can navigate to the upper level ...
5
votes
2
answers
2k
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
...
0
votes
0
answers
19
views
Multiline graphical table to seperate lines
I have a (very large) variable width table, something like this:
1
-----------------
2 | 3 | 4 |
| | ---- | ...
0
votes
1
answer
1k
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. ...
0
votes
1
answer
308
views
IPython %cpaste command freezes in Terminal mode
I try to use IPython's %cpaste to paste the clipboard content (Python code) to my Terminal which is launched via Neovim's terminal mode.
However, if I paste long lines of code, it freezes, and does ...
0
votes
1
answer
116
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
1
answer
56
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&...
1
vote
1
answer
198
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 ...
0
votes
3
answers
230
views
Paste in visual block mode
I would like to copy some text into 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 ...
0
votes
1
answer
125
views
Why do I need to type ggVVG to select all, instead of just ggVG? [closed]
Sometimes, ggVG does not work to select text. It will move the cursor to the top, but not select the text. This happens seemingly randomly. I have figured out if I type ggVVG it will work as expected. ...
0
votes
2
answers
597
views
How do I synchronize system clipboard and nvim clipboard?
I would like to synchronize the system and nvim clipboards so I don't have to do anything extra to copy and paste. I want to do (since I am on MacOS) command c to copy and command v to paste, inside ...
0
votes
0
answers
52
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 ...
7
votes
4
answers
2k
views
Why does `p` not put all yanked lines after quitting and reopening Vim?
I have the following workflow:
Open Vim
Use Visual mode linewise (V), select some lines, and yank them (y)
I get a message "151 lines yanked" or something like this
Quit Vim
Start another ...
0
votes
0
answers
23
views
Key combination to delete without copying to clipboard/register ? (General) [duplicate]
What's the command/option/keys/function that performs a delete on a selection (in visual mode) without copying the selection to clipboard/register? I.e I don't want to use d or x as they will delete ...
0
votes
1
answer
46
views
How to yank only to specified register and do not touch (change) default " register?
I have mapping for duplicating current line in insert mode:
inoremap <C-d> <Esc>`^mzYp`zi<Down>
I want to set up it in a way it does not change default " register by specifying ...
1
vote
1
answer
618
views
paste doesn't work in visual mode with `clipboard+=unnamed`
I am running VIM 8.1 with MacVim on MacOS.
If I set clipboard+=unnamed, then when I click p in visual mode,
it simply copies the currently selected text into "* and "+.
If I remove this and restart ...
0
votes
1
answer
61
views
How to copy content in + register from local vim to remote vim in good format?
vim1 is my local Vim. vim2 is the remote Vim.
ssh root@remote_ip
vim
#it is vim2
Now some content in my vim1's + register.
curl -X POST https://content.dropboxapi.com/2/files/upload \
--...
3
votes
2
answers
248
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
...
6
votes
1
answer
443
views
How does Vim knows if register contents were from a linewise selection when pasting?
I haven't been able to find documentation on how vim knows if register contents came from a linewise-selection vs characterwise or blockwise selection.
For example, given the text below:
Hello there ...
0
votes
2
answers
68
views
How do I cut lines to the clipboard?
In traditional text editors, we have two distinct operations that remove text from a document:
Delete, which removes the text
Cut, which copies the text to the clipboard before deleting it (as above)
...
0
votes
0
answers
13
views
How can I put a bullet point above or below the current line and have the same indent level automatically? [duplicate]
Let's say I have these bullet points
- First Line
- Second Line
- Third Line
On the second line I do dd, move down to the third line and do p, the second line gets pasted below with no indent, ...
1
vote
1
answer
70
views
Paste in front or after in visual-block mode?
I can enter visual-block mode using <C-v>, move down a couple of rows by pressing j several times, then paste some content from the registry via pressing p or P. However, the pasting will ...
0
votes
2
answers
172
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:
-...
23
votes
4
answers
2k
views
How does one append to the clipboard register in Vim?
I already know that you can copy something to the a register using:
(plus a yank, delete, etc. command)
"a
I also understand that you can append to the a register using:
"A
In addition I ...
-1
votes
1
answer
29
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)), &...
3
votes
3
answers
5k
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 = {
...
3
votes
2
answers
3k
views
Pasting text on Vim inside tmux breaks indentation
When pasting text into Vim without tmux, it shows a normal paste:
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Ut enim ...
1
vote
4
answers
47
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 ...
515
votes
15
answers
714k
views
How can I copy text to the system clipboard from Vim?
Is there a way to copy a block of text to the system clipboard, so I can paste it in another program?
2
votes
6
answers
4k
views
How to copy multiple lines and paste multiple times under each line separately?
original below. I want to copy each line and paste multiple n times under their own lines separately.
USD
XYZ
ABC
YUT
LMO
.
.
. upto so on
want them to become like this. Any way how can I achieve ...
1
vote
3
answers
385
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 ...
1
vote
2
answers
106
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.
0
votes
1
answer
280
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 ...
1
vote
2
answers
1k
views
How to override netrw-delete behavior?
I'm currently using Vim 8.1 on Ubuntu 18.04, and I would like to override the default behavior of deleting local files/directories 'forever' when using netrw.
The doc says that this plugin uses a ...
0
votes
4
answers
104
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 ...
1
vote
0
answers
69
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 ...