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".

449 questions
116
votes
16 answers

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 large block of text without having to know how many…
user579
103
votes
4 answers

How can I yank (copy) the single character on which the cursor rests?

I know many ways to copy things: yiw = yank in current word yaw = yank all word (includes a trailing space) yy = yank the current line 3yy = yank three lines starting at the current one yap = yank all paragraph (includes trailing newline) I can…
Christopher Bottoms
  • 3,772
  • 6
  • 22
  • 33
51
votes
5 answers

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?
pfrenssen
  • 613
  • 1
  • 5
  • 5
23
votes
4 answers

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 understand how to copy something to the clipboard register…
Jason Basanese
  • 969
  • 1
  • 8
  • 17
22
votes
10 answers

How to delete all white spaces until first character?

Is there a simple way to delete all white spaces on a line until the first character on that line is met? An example: #a list of comments # item 1 # item 2 And I would like it to become: #a list of…
calocedrus
  • 357
  • 1
  • 2
  • 6
17
votes
4 answers

Yanking and pasting while incrementing

I am editing a .sql file in Vim: INSERT INTO apps_forms (app_id, form_id) VALUES (1, 1), What I'm looking to do is yank the (1, 1), line and paste it 137 times; however, I want the second number in parenthesis to be incremented each time. The…
smoothgrips
  • 273
  • 2
  • 4
17
votes
7 answers

Deleting In Vim and Then Pasting Without new Line

Many times in vim I would like to delete a line completely, so I use dd. However, I then need to paste that line into some other position within a line, but this inserts a newline before pasting, therefore, making it very difficult for me to get the…
fYre
  • 450
  • 1
  • 5
  • 10
15
votes
2 answers

Delete from cursor till first character x (spanning multiple lines)

I know that I can delete from the cursor till and including the first occurence of a character x with dfx. This only works on one line. How can I delete from the current cursor position till the first occurence of x when x is not in the same…
user2609980
  • 729
  • 1
  • 6
  • 10
15
votes
1 answer

Does "dap" delete everything?

I'm familiar with the "dd" and "d{motion}" commands, but can't find "dap" in vim's help.txt. What does "dap" do in normal mode and why? (Alternatively, how can I find out this sort of thing for myself?)
lsusr
  • 253
  • 2
  • 8
14
votes
1 answer

Why did p paste a copied line after the current line, instead of after the current word?

Suppose I have the following four lines: line1 line2 line3 line4 Now if I go to line1 and do a yy which copies the line and then go to start of line3 and do a paste using 'p', I would get ... line3 line1 line4 .... Why did it paste line1 after…
James Franco
  • 1,101
  • 1
  • 9
  • 15
10
votes
4 answers

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 but perhaps is there an easier way. Edit: dG doesn't help here as it…
Rob Bar
  • 123
  • 1
  • 8
10
votes
1 answer

how to yank from vim to system clipboard?

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 need to yank parts of it and paste them into a web…
Kes
  • 663
  • 1
  • 8
  • 18
8
votes
1 answer

Avoid extra spaces while pasting block with different line lengths

I have the text var1=a var2=aaa var3=aaaaaa some text... "" ... some text... "" ... some text... "" ... I want to paste the a-part of the top 3 lines into the quotes in the last 3 line. The result should look like this some text... "a" ... some…
Boris Brodski
  • 671
  • 7
  • 19
8
votes
2 answers

How to move a paragraph and paste it without an initial newline first

If I have a pair of quotes on a line by themselves: '' ...and a short paragraph of text, say three lines of text: some text that I'd like to move Now if I want to move the text into the quotes, I can place the caret at the line above the first…
Kjartan
  • 183
  • 1
  • 6
8
votes
2 answers

delete words backwards

I use Vim 7.4.576 on debian8. I don't grasp the concept of deleting words backwards. Here is some text. Cursor position is on "that" (the pipe symbol) this is a new text on th|at line. How can I delete the previous words, so as a result the…
rtl33
  • 81
  • 1
  • 2
1
2 3 4 5 6 7 8