Questions tagged [yank]

yanking is the older word for copying a line to a clipboard. Use this tag to ask about how the command is working, or advanced combinations.

yanking is the older word for copying a line to a clipboard. This is favoured in UNIX text editors such as and . Use this tag to ask about how the command is working, or advanced combinations/commands which involve yanking several lines.

68 questions
270
votes
11 answers

How to select between brackets (or quotes or ...) in Vim?

I'm sure there used to be a plugin for this kinda stuff, but now that I need it, I can't seem to find it (naturally), so I'll just ask nice and simple. What is the easiest way to select between brackets, or quotes, or generally a list of matching…
Rook
  • 60,248
  • 49
  • 165
  • 242
249
votes
13 answers

Yank file name / path of current buffer in Vim

Assuming the current buffer is a file open for edit, so :e does not display E32: No file name. I would like to yank one or all of: The file name exactly as show on the status line, e.g. ~\myfile.txt A full path to the file, e.g.…
davetapley
  • 17,000
  • 12
  • 60
  • 86
97
votes
10 answers

Vim yanking range of lines

I'm a C# developer who has just recently decided to expand my knowledge of the tools available to me. The first tool I've decided to learn is Vi/Vim. Everything has been going well so far, but there are a couple of questions I can't seem to find…
jnadro52
  • 3,454
  • 3
  • 21
  • 17
49
votes
2 answers

Vim: Replace selection with default buffer without overwriting the buffer

Here is my problem: I am in visual mode. I select text and copy it to the buffer. ((y)ank) I select another text which I want to replace and paste the buffer. ((p)aste) Now the second selection has been replaced in the buffer, however I want the…
Juergen Riemer
  • 1,393
  • 2
  • 13
  • 29
34
votes
8 answers

Emacs: How to yank the last yanked text regardless of subsequent kills?

I often find myself repeatedly yanking something after doing some kills and it becomes a process like: C-y C-y M-y C-y M-y M-y C-y M-y M-y M-y Each time I kill some text it pushes the first kill back in the kill ring so that I need to cycle…
Reed G. Law
  • 3,897
  • 1
  • 41
  • 78
28
votes
5 answers

Vim "yank" does not seem to work

I'm fairly new to Vim. Tonight, I learned about the "yank" command, but when I try to use it in MacVim, it doesn't do anything. Neither Y nor y{motion} do anything. I tried with a default .vimrc to rule out any weird config issues. Google-fu is…
Adam Rubin
  • 777
  • 1
  • 7
  • 16
22
votes
1 answer

Why does "yank" have the meaning of "copy" in Vim?

yank: to pull on something with a quick vigorous movement How does "yank" correspond to the copy functionality in Vim?
showkey
  • 482
  • 42
  • 140
  • 295
15
votes
4 answers

vim yank all matches of regex group into register

I know that I can yank all matched lines into register A like this: :g/regex/y/A But I can't seem to figure out how to yank match regex groups into register A: :g/\(regex\)/\1y A (E10: \ should be followed by /, ? or &)
user2506293
  • 805
  • 1
  • 7
  • 13
12
votes
4 answers

Vim - capture in between slashes?

Is there a motion for capturing text in between / or \? I know there is motions for other symbols --- ci" - Capture 'text' inside "text" vi( - Visual capture int var inside foo(int var) di[ - Delete word [word] into [] The only workaround I can find…
dook
  • 1,213
  • 1
  • 13
  • 30
12
votes
1 answer

insert something into kill ring in Emacs

I want to write a function that will insert the file name of the current buffer into the kill ring so I can yank it to the terminal in another window. How can I programmatically insert a string into the kill ring? (
jcubic
  • 61,973
  • 54
  • 229
  • 402
12
votes
2 answers

Change location of vim yankring history file

The yankring plugin for Vim creates a file in my home directory called yankring_history_v2.txt. How do I tell the plugin to store this file in another location?
cydonian
  • 1,686
  • 14
  • 22
11
votes
4 answers

How can I make vim remember past yanks? (Or configure YankRing to do less.)

When I delete something in vim, it's added to the numbered registers. The last item I yanked is in register 0. How can I get vim to automatically remember the last 10 yanks too? I've tried YankRing, but it changes too much of vim behavior. An…
idbrii
  • 10,975
  • 5
  • 66
  • 107
11
votes
5 answers

How do I yank to system clipboard in Kakoune?

If I yank a word in kakoune, how do I paste it into another editor (e.g. gedit)? I have read How to make vim paste from (and copy to) system's clipboard? since vim is very similar but kakoune does not have any * register.
Ford O.
  • 1,394
  • 8
  • 25
11
votes
4 answers

How to yank between files?

For example, when I yank some text from vim, then :wq, and open a new file. When I try to paste the text I just yanked, it doesn't work. So how to yank text between files?
OneZero
  • 11,556
  • 15
  • 55
  • 92
10
votes
4 answers

Highlight copied area in Vim

I would like to mimic a nice effect found in the game Vim Adventures: When a yank command is done, I would like the yanked area to be highlighted (let's say in red) for a second to show me that my selection was correct. For example, yy would…
user2854544
  • 851
  • 1
  • 11
  • 23
1
2 3 4 5