標籤:

為什麼在 vi 的世界, 拷貝都使用 yank 這個詞, 而不是 copy?

yank 是 猛拉 的意思, 實在沒法和複製聯繫起來呀.

是因為 vi 太古老, 歷史原因造成的用 yank 這個詞么.

很好奇這個歷史故事


對 Emacs 來說,yank 是粘貼,save-to-kill-ring 才是複製。

vi 複製和粘貼都叫 yank。

因此可看出 yank 和中文的「複製」不是直接對應的。Yank 準確的意思應為把文本把拖入/出寄存器/Kill-Ring是也。


Vim 的 User Manual(Vim documentation: usr_04) 里有提到:

*04.6* Copying text

To copy text from one place to another, you could delete it, use "u" to undo

the deletion and then "p" to put it somewhere else. There is an easier way:

yanking. The "y" operator copies text into a register. Then a "p" command

can be used to put it.

Yanking is just a Vim name for copying. The "c" letter was already used

for the change operator, and "y" was still available. Calling this

operator "yank" made it easier to remember to use the "y" key.

VIM: usr_04

要把文本從一個地方拷貝到另一個地方,你可以先刪除它,然後用 "u" 命令恢復,再用

"p" 拷到另一個地方。這裡還有一種簡單的辦法: 抽出 (yank)。"y" 命令可以把文字拷

貝到寄存器中。然後用 "p" 命令粘貼到別處。

yanking 是 Vim 中拷貝命令的名字。由於 "c" 已經被用於表示 change 了,所以拷

貝 (copy) 就不能再用 "c" 了。但 "y" 還是可用的。把這個命令稱為 "yanking" 是為

了更容易記住 "y" 這個鍵。
(譯者注: 這裡只是把原文譯出以作參考,"抽出" 文本畢竟

是不妥的。後文中將統一使用 "拷貝"。中文可不存在 change 和 copy 的問題。)

再刨根問底,只能去問 Bill Joy 了。讀讀 Vi 的 History vi - Wikipedia ,會有一些有意思的發現。比如 Bill Joy 當時用的鍵盤,看看 Esc 鍵的位置, 複製是很常用的命令,純鍵盤操作的話,直覺上應該是用食指去敲那個字母命令為好,最好還與粘貼命令在鍵盤同一行( Windows 下Ctrl+X 剪切,Ctrl+C 複製, Ctrl+V 粘貼,X、C、V 三個鍵都在同一行),p 是粘貼的話,y 作為複製命令是不錯的選擇,畢竟 QWERTY 鍵盤就這麼設計的。那怎麼記住 y 是複製呢?就想到 yank 了(順便粘貼 p -&> put 而不是 paste ,因為 put 和 yank 頗為對眼),術語都是人定的。假如,我說的是假如哈,把 y 作為剪切(cut)命令,可能就說 y 代表著 yield(放棄)了。

補充閱讀:

- Practical Vim by Drew Neil

- 中文版: Vim實用技巧 (豆瓣)

Tip 60 Grok Vim』s Registers

技巧60 深入理解Vim 寄存器

Vim』s Terminology Versus the World

Vim 術語對照表

- The cut, copy, and paste terminology is universally understood, and these operations are available across most desktop software programs and operating systems. Vim provides these features too, but it uses different terminology: delete, yank, and put.

- 剪切(cut)、複製(copy)與粘貼(paste),這些都是眾所周知的術語,而且大多數桌面軟體和操作系統都支持這3類操作。Vim 當然也提供這些功能,只不過使用的是另外的術語 delete、yank 與 put 。

- Vim』s put command is effectively identical to the paste operation. Fortunately, both words begin with the letter p, so the mnemonic for the key command works whichever terminology we use.

- Vim 的 put 命令與粘貼操作完全相同。幸運的是,兩詞均以字母 p 開頭,因此即使術語不同,也不會影響記憶。

- Vim』s yank command is equivalent to the copy operation. Historically, the c command was already assigned to the change operation, so vi』s authors were pushed to come up with an alternative name. The y key was available, so the copy operation became the yank command.

- Vim 的 yank 命令也等同於複製操作。但由於歷史原因,當時c 命令已經被用於修改(change)操作了,因此Vi 的作者們被迫選擇了另一個名字yank。由於那時y 鍵還可用,因此它就成了複製操作的命令。

- Vim』s delete command is equivalent to the standard cut operation. That is, it copies the specified text into a register and then removes it from the document.

- Vim 的delete 命令也與標準剪切操作的作用一致。也就是說,該命令會先把指定文本複製到寄存器後再從文檔中刪掉。

……


就是這樣。。


不怎麼用vim但是用Emacs,emacs裡面Ctrl+K是kill殺死,Ctrl+Y是yank拉回(復活23333)而且剪切板就叫kill-ring沒毛病。至於Ctrl+W/Alt+W我就不知道什麼來歷了…反正是為了防止衝突吧後來就成習慣了沒必要改,就好像shell裡面Ctrl+Z是休眠,所以撤銷用的是Ctrl+/一樣


copy的c被改變 change 佔了

所以只能挑個順手的不常用的鍵代替了


cuz vi is created by yankees


推薦閱讀:

vim 裡面怎麼清空一行的內容而不刪除一行?
如何把vim打造成一個真正的IDE?
「配成准IDE的vim」和「裝了vim插件的真IDE」哪個效率更高?
用 Vim 的人如何解釋現在大多數公司都要求用 IDE 這個局面?
Vim 比起 IDE 的優勢是什麼?

TAG:Vim |