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
3answers
97 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-...
9
votes
4answers
2k 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 ...
1
vote
2answers
77 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 ...
3
votes
5answers
116 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 ...
5
votes
3answers
357 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
34 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
19 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
225 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
36 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
43 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
91 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
45 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
73 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
30 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 ...
383
votes
12answers
398k 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
28 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
85 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
45 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
40 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
721 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
44 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 ...
77
votes
6answers
84k 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
39 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 ...
2
votes
5answers
498 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 ...
1
vote
1answer
187 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
24 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
36 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
100 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
188 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
133 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
44 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 ...
0
votes
1answer
153 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 ...
3
votes
1answer
158 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 ...
102
votes
16answers
81k 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
57 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 ...
2
votes
2answers
280 views

How to activate bracketed paste mode in GNOME Terminal for Vim inside tmux

Edit this issue happens inside a tmux session. The original value of $TERM before starting vim is: echo $TERM screen The issue appears for example when pasting this kind of indented code: def ...
4
votes
0answers
58 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
1answer
32 views

How can I make Neovim actually delete something instead of copy?

I find very frustrating in Neovim and vim that when I delete a text to replace it, what actually happens is that it copies the last thing I deleted. I've tried with this line in my init.vim: vnoremap ...
2
votes
1answer
49 views

Yank visual selection with modifications in a terminal-buffer

Upon writing a code, sometimes I open a terminal split with :term to test it by issuing some commands and checking some output. As an example, this is a fragment of what I have executed in a split ...
3
votes
1answer
50 views

Append to current copy buffer

I am copying multiple lines from different parts. I can for example do 3yy to copy the 3 next lines. Then I would like to scroll a bit and add 5 more lines: 5yy and so on. At the end, I want to paste ...
0
votes
1answer
52 views

How to paste/merge 2 blocks of text in vim

I search a way to paste/merge 2 block of text block A apple pear banana block B tomato beans potato to this apple tomato pear beans banana potato I'm looking for an easy way to do this using macros....
0
votes
2answers
29 views

How to delete strings to close quote and close parenthese

I have a code like this: h5 style=("text-align: center; margin-top: 2rem;") some text p style=("text-align: center; margin-top: 2rem;") some text And in first line, I want to ...
3
votes
3answers
100 views

Paste a block-copy into a single line

I need to restructure a markdown table, and for that, I wish there was a quick way to "join" lines from a multi-line cell. So with Vim, I would have to yank the block (Ctrl-v), and then ...
4
votes
5answers
183 views

Can I define something in .vimrc to speed up pasting of large amounts of data?

Occasionally, I paste large amounts of data into vim, using Ctrl+v in my terminal emulator (in Linux). This takes several seconds before vim is responsive again. I have tried two other methods, which ...
2
votes
3answers
294 views

Is there a quicker way to replace the content in parentheses with the content yanked?

If I want to replace something inside a group of parentheses (like say a function call) with something I've yanked I currently do: vi(p this obviously isn't an excessive use of the keyboard, however I'...
0
votes
1answer
20 views

How to delete and replace a block of text with spaces?

What I want to do I want to select a block of text in Vim, delete it, and replace the selected block with spaces. Example Suppose I have the following text: Lorem ipsum dolor sit amet, ...
2
votes
0answers
36 views

Copy all text in Vi and then paste it to another application on another system

I connect to Linux server via SSH using Putty terminal. I open a file with Vim and press ggVGy in order to select all text and copy it. But when I try to paste the copied text to Windows Notepad, it ...

1
2 3 4 5
7