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

Yanking into register within a script is not working

Given a file like this: Roy Maurice Jen Douglas If I were to type the following commands: ggVj"zy, followed by :reg z, I would see Roy and Maurice. Now I want to yank Jen and Douglas into the z ...
1
vote
3answers
159 views

Pasting text on Vim inside tmux breaks indentation

Ubuntu: 18.04 bionic tmux: version 2.6 VIM: Vi IMproved 8.0 (2016 Sep 12, compiled Jun 06 2019 ) Included patches: 1-1453 Modified by pkg-vim-maintainers@lists.alioth.debian.org Compiled by pkg-vim-...
43
votes
5answers
11k views

How to yank a line with a certain line number?

Say that I am on line 20 and I would like to yank line 4, how can I do that? And similarly, how can I yank a line relative to my cursor position, say the one 3 lines up?
0
votes
0answers
12 views

How do you disable automatically copying text when pasting over it in visual mode so you can paste the same thing multiple times? [duplicate]

Like the title says, if I have yanked some text, then select what I want to replace in visual mode, press p to paste, I want the original text still available to paste in other locations. I never ...
0
votes
0answers
27 views

How to bind <C-U> to <Cmd><BS> in vimrc?

I understand that <C-W> is backward-kill-word and I have bound this to shiftBS and it works. But now I want to bind <C-U> to cmdBS. Is this possible? If so, how can I do this?
0
votes
1answer
29 views

How to copy text to clipboard in visual mode? [duplicate]

I ran the following sequence of commands: V10j ⌘ c but it seems like this doesn't copy the ten lines to my clipboard. So how can I do this?
2
votes
1answer
1k views

how to yank from vim to system clipboard? [duplicate]

I'm using the latest version of vim 8.2.148 on the latest version of arch linux 5.5.6-arch1-1 with the latest version of Openbox window manager version 3.6.1. I have written a document in vim and ...
1
vote
2answers
41 views

paste in insertmode without indent i.e. `<C-r>*` without indent

I want to do :set paste, paste, :set nopaste in one keyboard shortcut in insertmode (<C-r>*) In visualmode, with vnoremap p "+p works with no indent. But in insertmode, this <C-r>* ...
1
vote
1answer
37 views

Delete/yank into multiple registers at the same time?

Is there a way to have y/d/c/x/s output into multiple registers at the same time - for example, "a as well as the system clipboard "+? I can do "aY"+Y obviously, and with Y it's ...
3
votes
6answers
152 views

Quickest way to put a single piece of text in multiple lines

Sometimes I have a bunch of lines, where there's a column clearly indicating some commonality between them, which in general doesn't go far beyond that column; this is an example, I think general ...
2
votes
6answers
567 views

How to delete a pair of parenthesis with backspace

I'm using vim to code C++ and I want to handle the parenthesis more easily. I knew that there was a plugin named Surround, which can help us but it is not what I expected. I set some shortcuts as ...
2
votes
2answers
100 views

optimise surround with quotes

I want to surround a word with quotes Here is my set of commands: ciw then when I am in insert mode, I type ' (I use the vim extension on Visual code so I get two ' I do not know if it the case for &...
1
vote
2answers
422 views

Copying lines in visual mode only lets me paste 2 lines

I don't really know a better way to describe this, but copying multiple lines in Visual Mode flat out doesn't work. I hit V, highlight the lines, hit y, and then it will tell me "31 lines yanked" (or ...
2
votes
1answer
29 views

Delete up everything until searched term, including searched term

If the cursor is at t in the quick brown fox and we type d/brown, we delete the quick . Is there a way to extend this such that the searched term is deleted too? (Such that only fox remains.)
3
votes
2answers
66 views

Reliably saving and restoring registers across a function call [duplicate]

When writing functions to use in mappings and user-defined commands (for plug-ins), it's often convenient to use a Normal-mode command to yank or delete buffer contents. In those cases, it's also nice ...
0
votes
1answer
164 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 ...
1
vote
2answers
153 views

Yank a line without a line break or moving the cursor

I want to have a key binding to yank the current line into the system clipboard. My current mapping is as follows: nnoremap <C-y> "+yy However, this also yanks the newline. I often use ...
9
votes
4answers
3k views

How to copy text with syntax highlighting?

Want a simple way, like notepad++ plugin: NppExport - Export to RTF, to copy selected text with syntax highlighting. Notepad++, NppExport, Export to RTF example: Select text Copy RTF Paste ...
5
votes
3answers
377 views

Prevent the cursor from moving to the start of the yanked text?

Vim help's change.txt states that Note that after a characterwise yank command, Vim leaves the cursor on the first yanked character that is closest to the start of the buffer. This means that "...
1
vote
2answers
23 views

make da( or dab remove lagging whitespace like daw

TL;DR: da( doesn't delete the following space like daw does. Can I make this do what I want easily? I have some sample lines (cursor is shown as |): 1. Sample line (extraneous| statement) in notes. 2. ...
3
votes
1answer
35 views

Need a functionality behaving like Replace on text but for Pasting Blocks

One of my vim usages is to do sketches of topologies in networking I've found the script Draw it really really useful for that So I can draw things like this by pasting these boxes +------+ |ROUTER| ...
1
vote
1answer
22 views

How to prevent cursor shift when using <C-O>{delete cmd} at the end of a line?

<C-w> deletes a (small-)word in insert mode, but I often want to delete the Word (to last whitespace) I've most recently typed. I tried inoremap <C-_> <C-o>dB which kind-of works -- ...
3
votes
3answers
246 views

How to quickly swap words (around pivot)

I have this: Alice --> Bob Dave --> Eve and want to change that to this: Bob <-- Alice Eve <-- Dave Changing from --> to <-- can easily be done with :s/-->/<--/, but swapping ...
0
votes
1answer
38 views

How can I make backspace work in visual block mode?

I hit Ctrl-v3jShift-ixEscape, and x is correctly inserted on the current line and in the 3 lines below it in the same column. Good. I hit Ctrl-v3jShift-iBackspaceEscape a character is deleted only on ...
1
vote
1answer
48 views

Yank inside quotes of a range of lines to a register and separate them with a new line character

I would like to populate a register with the text inside quotes for a range of lines. The register should contain all yanked text separated with new line characters. Example lines: The "black" cat A "...
2
votes
0answers
130 views

Vim adding blank line after each line when pasting from clipboard

When I copy-paste multiple lines from clipboard into my vim, it inserts a blank line after every line. But when I copy in into a text editor first and then copy-paste it into vim, the blank lines are ...
2
votes
1answer
51 views

How do I enable copy/paste between vim and tmux in both two directions?

In a tmux session, I'm running vim in one pane and a terminal in another pane. Recently, I figured out how to enter visual mode in tmux but it doesn't help much now. Can I yank selected text from a ...
2
votes
1answer
101 views

How do I copy the URL under the cursor?

In Vim, I can use gx in normal mode to open the URL under the cursor. Instead of opening the URL, how can I copy the URL? I am looking for something faster than entering into visual mode, selecting ...
1
vote
1answer
31 views

How to switch the order in which objects appear

I have a custom command in a TeX file which takes two inputs A and B, let's call it \operation{A}{B}. I want to find all of the instances of \operation where the first entry A starts with the string ...
398
votes
12answers
415k 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
2answers
1k views

How to disable bad indentation when pasting text?

I am using vim and simply want to disable auto indent when I paste text into my terminal vim session. I have tried numerous solutions including various incantations of below to ~/.vimrc: set nopaste &...
0
votes
1answer
40 views

Inline paste from System Clipboard

I have recently started using Neovim on Windows 10. I use "+p to paste from the system clipboard. But sometimes I just want to paste inline before or after the cursor without adding a new line. ...
0
votes
5answers
98 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
1answer
77 views

Problem pasting text with brackets when using auto-close functions/plugins

It's nice to have an auto-close plugin for brackets and quotes like coc-pairs. However, when I paste text from outside into vim insert (ctrl-C, ctrl-shift-v), the text seems to be pasted character-by-...
0
votes
3answers
44 views

How to copy the selection to clipboard without the indentation that is relevant just in the full file, not in the selection?

With other words: How to copy selection without its root-level indentation? Example: How to copy this: a b c d instead of: a b c d I am using Neovim inside VS Code ...
1
vote
1answer
782 views

How to use a value stored in a variable in the command mode?

Consider the following function function! AbbreviationsOpen() "go to the first word of the last line normal G "store the word in the register named a let @a = expand('<cword>') ...
-1
votes
1answer
51 views

Paste clipboard data in Insert mode

I have learnt to paste clipboard data (something i copied from web browser using ctrl+c) to my current buffer in insert mode. It is much easier than doing that in Normal mode. To paste clipboard data ...
79
votes
6answers
89k views

How can I easily move a line?

What is the command (or shortcut) to move a line up or down in vim? My current workflow is to yank (copy) the line and than delete that line and than to put (paste) that line.
0
votes
1answer
41 views

clipboard not activated

I installed vim from their github repo. But I cannot seem to copy paste with from the system clipboard. So, I explored a little and tried to install vim-gtk package which would enable the clipboard ...
0
votes
0answers
23 views

How to paste text from other applications into Vim without incrementally indenting each pasted line? [duplicate]

I want to copy text from other applications into Vim, e.g. from Visual Studio Code, but the result is awful. In particular, each pasted line is being indented incrementally: Furthermore, visually ...
1
vote
1answer
327 views

Yank multiple lines without using visual mode

I have the text: abcd abcd abcd abcd my cursor is in the first line, and I want to yank the first 2 lines. Usually I would do it by pressing Shift+v, selecting the second line by going down with j ...
0
votes
1answer
26 views

Grep for a pattern using current visual selection on another file

I want to basically search for a pattern in the current file on another file, from vim, using the current visual selection. I know doing: :grep pattern otherfile works, but i want the 'pattern' to be ...
1
vote
1answer
40 views

Vim filter command not using line-wise selection

I may have seen this question before on Vi Exchange but I'm having trouble locating it while searching now. If it's already been answered, please let me know the duplicate and I can find that. I have ...
1
vote
2answers
127 views

How can I paste text appending it to the end of each line? [duplicate]

If I have file1.txt which contains the following: Line 1.1; Line 1.2; Line 1.3; and file2.txt with the following Line 2.1; Line 2.2; Line 2.3; I want to copy all the lines of file2.txt and paste it ...
1
vote
1answer
247 views

Custom g:clipboard results in `p` always pasting into the same line

Background I use wayland and neovim and when pasting external text it would add ^M to the end of each line. This is a known "bug" (https://github.com/neovim/neovim/issues/10223) and there ...
3
votes
2answers
163 views

Vim not storing numbered registers

I've read that Vim automatically stores previously yanked texts into registers from 1 to 9, being 1 the previous yank, 2 the second previous, and so on... But this is not working for me. Here is a ...
2
votes
1answer
58 views

Text get weird staircase indent on copy

I copied this file to vim and enumerated items got weird staircase pattern indent. Why so and how can I prevent this text corruption on a copy? It seems that it happens not only with enumerated items ...
3
votes
1answer
200 views

Date change question: Find and replace with wildcards?

I have a file with a bunch of dates of the form a/b/c, where a,b, and c are numbers of varying character length. However, I'd like to change every instance to read c/a/b. I'm wondering if there is a ...
105
votes
16answers
83k views

How do I delete a large block of text without counting the lines?

In vim, I often need to delete, or yank/put large blocks of text. I can count the lines of text and enter something like 50dd to delete 50 lines. But that's a bit of a pain. How can I delete this ...
2
votes
1answer
63 views

Can't Copy Non-ASCII Characters

I can't copy Non-ASCII charaters from Neovim anymore when I select them with mouse or crtl + v. For example, I have the Turkish word Bankası written in my editor. When I yank and paste it to somewhere ...

1
2 3 4 5
7