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".
327
questions
3
votes
1answer
344 views
“x” overwrites clipboard, I am not able to finish the copy-pase action [duplicate]
I decided that I have to get rid of a couple of annoying things which decrease my productivity in Vim. I know they must have a simple solution.
So, my first question:
If I copy a word in clipboard ...
2
votes
1answer
141 views
How do you get which “side” of the visual mode selection the cursor is on in vimscript?
I'm writing some vimscript and would like to preserve the cursor position after a yank occurs in visual mode.
Ths issue is that I can't find any way to get the cursor position while in visual mode. ...
3
votes
1answer
841 views
How do I copy the error message I get from YCM
Is there a way to copy the error message that YCM shows at the bottom of vim?
For example in the above image, it says:
unused parameter 'sortFunction'
I had an idea of using "howdoi [paste]" in ...
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.
2
votes
1answer
101 views
How to copy the current line(s) out to a new file?
I'm reading through a very large web service log, and I want to pull a single line out from the file, and write it to a new file.
The log lines consist of web service request XML, so they are long ...
18
votes
1answer
2k views
How can I map d[count]d?
N.B. This is not a duplicate of How does the "d3fg" command work? Please read it before voting to close!
I've come to a bit of an impasse in my quest to get small deletions work like big ...
5
votes
2answers
969 views
Keep cursor from moving when yanking upwards
I frequently find myself wanting to make a copy of, eg, a function that I just wrote and modify it slightly. In such a situation, I'll generally use something like y5k to copy what I just wrote. I ...
32
votes
5answers
2k views
Is there a text object for the entire buffer?
I often find myself typing commands like gg"+yG or ggdG and would like a more efficient way to do this without having to move the cursor twice. Is there any command that I can use e.g. y[movement] to ...
5
votes
1answer
490 views
How does the “d3fg” command work?
I would like to know how a "d3fg" command works in vi.
I have done some research on Google and found that d is delete and fg means foreground. Suppose, if we want to stop the session of vi and resume ...
4
votes
3answers
2k views
How do I switch around 2 pieces of text?
I have 2 pieces of text, what is a proper way to switch those pieces of text. around e.g. I have this:
This is one piece of text.
Here is another sentence.
And I want to switch around the 3 first ...
6
votes
4answers
19k views
How do I copy and paste between two vim instances - shared clipboard?
I use gnu screen and I run vim file1.txt and vim file2.txt in two windows.
How can I copy part of the text from file1.txt and paste it to file2.txt
without using temporary files or opening two files ...
4
votes
2answers
2k views
How can I get vim to not auto-wrap pasted text? [duplicate]
I am pasting several lines of text into vim at once (from another application, so I am using the OS's copy and paste and insert mode in vim). The longest of these lines is below:
" :PluginClean -...
10
votes
2answers
425 views
Most efficient way to replace the entire buffer?
Currently, I have two similar methods to replace the entire buffer with some other text (say in clipboard).
Method #1:
delete all lines: :%d.
paste text: "+P ( or similar: :put+).
Method #2:
...
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 ...
1
vote
0answers
18 views
do a command without altering the register [duplicate]
Sometimes I delete a line and when I want to yank it somewhere else I found out that I need to delete another line.
How can I delete the new line without overriding the the content of the line that I ...
6
votes
2answers
8k views
How to select and copy lines to clipboard which are selected by mouse without linenumbers and gutter?
In my default Vim settings I've enabled a gutter and line numbers. Sometimes I copy some lines to clipboard in order to paste somewhere else. Currently I need to disable line numbers and the gutter. ...
4
votes
2answers
130 views
Can I paste a yanked line even if I delete a line? [duplicate]
When I yank a line with y and paste it with p, it's okay. But when I need to delete a line with dd before pasting my yank buffer changes. Can I still paste my yanked line? Is there a way to do that?
...
5
votes
2answers
4k views
How does one perform a multi-line copy and paste between two sessions in Vim?
I am familiar with the y, p method of copying and pasting a line within Vim; however, I have been unsuccessful in finding a straight forward method for copying multiple lines which have been yanked in ...
27
votes
7answers
7k views
Faster way to move a block of text
Here's how I usually copy a block of text or code:
Select the block with Visual mode (V) and delete it with
d; or if it's just a single line, just use
dd.
Go to where I want the text to be, I am too ...
4
votes
2answers
157 views
How to paste and remove current line
For example if I copy several lines of text and open a brand new file. If I paste with p, then I get an empty line above the pasted text, and if I paste with P, I get an empty line below the pasted ...
6
votes
2answers
246 views
Working with English sentences
When I'm editing English text, I need to work with full sentences instead of lines of text in the file. Using the default Vim commands for this kind of text manipulation is very awkward, because I may ...
10
votes
3answers
408 views
How can text be moved from one register to an arbitrary number of registers?
Is there a way to 'pipe' text from a register to an another register or set of registers? For example, move "q to registers "1 through "5.
I often wish to create slightly different versions of the ...
1
vote
1answer
237 views
What can happen if I accidentally paste into command mode? What should I do if I do this? [duplicate]
If I have vim in a windowed terminal, sometimes I paste (using the terminal's paste functionality, e.g. middle click) from another window that isn't vim. Most of the time, when I do this, I wanted to ...
33
votes
5answers
2k views
Performing certain operations without clearing register
Frequently, in configuration files I might copy and paste a block of lines, then I want to make small changes to that block. After pasting, I use x to delete characters that I want to remove, then ...
10
votes
1answer
164 views
Overwrite current line with register?
I often want to copy a line and replace another line with the pasted copy. Is there a better way than Y on source line, go to the line that has to be replaced and Pjdd?
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?
15
votes
3answers
1k views
How do I visually select the block of text I just pasted in Vim?
I usually need to move/copy code snippets between my source files. After I paste a block of text, I usually need to apply some operation to that block such as reindenting them with =.
Is there a way ...