I have a very short question that I couldn't really find anywhere else upon googling, though to me this feels like a very natural question to ask, so maybe it's just I'm missing out on something.

So the word YANK feels like it means the opposite in Bash and Vim.

  • In Bash, Copy and Paste is Kill and Yank. Hence we use ctrl-y to paste the text stored in the kill-ring (or, yanking text from kill ring, as in pulling.
  • In Vim, Copy and Paste is Yank and Paste. Hence we use simply p to paste. But we use y to copy text to buffer.

Therefore it feels like to me that in Bash Yank is Copy and in Vim Yank is Paste. In English, Yank means "to pull", so I think it makes more sense to take Yank as Pulling data from buffer / kill-ring (so yank = paste).

But since I couldn't really find any discussion about this, I think there must be a very reasonable explanation for the above question. If anyone can help me understand this, it'll be appreciated!

Thank you!

  • 1
    so, what is the problem? ... what is there to understand?
    – jsotola
    Mar 18, 2023 at 1:57
  • "Pulling data from buffer" ... you do know that what you're editing in in Vim is called a buffer? vim.fandom.com/wiki/Vim_buffer_FAQ
    – muru
    Mar 18, 2023 at 9:01
  • Hey Jsotola, thanks for your comment. What I wanted to know was how/why the same word, yank, is used to mean different things (opposite direction).
    – jshji
    Mar 19, 2023 at 2:41
  • Hey muru, yes, and you do know that "the operator y yanks a copy of the object which follows into the unnamed buffer? ;) github.com/dspinellis/unix-history-repo/blob/…
    – jshji
    Mar 19, 2023 at 2:43
  • Thanks for sharing the link! That looks like a good learning resource :)
    – jshji
    Mar 19, 2023 at 2:43

1 Answer 1


bash (or rather readline which is the line editing library used by bash) like most other shells since the early 80s has two line editing modes: emacs or vi, based on those two popular text editors.

Bash being the GNU shell and GNU emacs being one of GNU's star applications, the default mode there is emacs. You can switch between both with set -o emacs and set -o vi (also bindkey -e/bindkey -v in tcsh or zsh). Ksh also has set -o gmacs for Gosling emacs which is the one set as default on Solaris for instance.

So it's more about the different of meaning of the yank word in emacs vs vi.

Both emacs and vi were written in the late 70s long before either bash (1989) or vim (1991).

If you look at the vi doc from 2BSD from 1979:

The operator y yanks a copy of the object which follows into the unnamed buffer. If preceded by a buffer name, "xy, where x here is replaced by a letter a−z, it places the text in the named buffer. The text can then be put back in the file with the commands p and P; p puts the text after or be‐ low the cursor, while P puts the text before or above the cursor.

Emacs doesn't have paste buffers, it has one killring that records text that has been killed or copied into it. The yanking is seen as being in the other direction, pulled from that killring as opposed to pulled from the text into the kill ring.

In GNU emacs doc from around 1985, we find:

Yanking is getting back text which was killed. The usual way to move or copy text is to kill it and then yank it one or more times.

You'd see that bash has widgets from both editors that can bind to keys or key combinations:

$ bash -c 'bind -l' | grep -i yank

(the vi ones being mostly undocumented).

Default bindings:

$ bash -o vi -c 'bind -pm vi' | grep yank
"_": vi-yank-arg
# vi-yank-pop (not bound)
"Y": vi-yank-to
"y": vi-yank-to
"\C-y": yank
# yank-last-arg (not bound)
# yank-nth-arg (not bound)
# yank-pop (not bound)
$ bash -o vi -c 'bind -pm vi-insert' | grep yank
# vi-yank-arg (not bound)
# vi-yank-pop (not bound)
# vi-yank-to (not bound)
"\C-y": yank
# yank-last-arg (not bound)
# yank-nth-arg (not bound)
# yank-pop (not bound)

See how you still get a emacs-style Ctrl+y in vi insert mode; the undocumented vi-yank-arg bound on _ also uses emacs-style terminology and behaves similarly to the yank-last-arg emacs widget. I have no idea what vi-yank-pop is meant to do. The NEWS file from the bash source distribution says it's a vi-mode version of emacs-mode yank-pop, though that doesn't make sense since vi has no kill-ring.

  • Hello Stephane, thank you so much for your answer! I didn’t know bash was using emacs, and so my question is actually about the difference between emacs and vi. It looks like the reason why they mean different (opposite) things is simply the design choice of the developers of vi and emacs.
    – jshji
    Mar 19, 2023 at 2:50
  • Thank you so much for finding and including the links to those references as well!!
    – jshji
    Mar 19, 2023 at 2:55

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .