为什么在 vi 的世界, 拷贝都使用 yank 这个词, 而不是 copy?

您所在的位置:网站首页 copy命令是什么意思 为什么在 vi 的世界, 拷贝都使用 yank 这个词, 而不是 copy?

为什么在 vi 的世界, 拷贝都使用 yank 这个词, 而不是 copy?

#为什么在 vi 的世界, 拷贝都使用 yank 这个词, 而不是 copy?| 来源: 网络整理| 查看: 265

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

*04.6* Copying textTo copy text from one place to another, you could delete it, use "u" to undothe 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" commandcan be used to put it. Yanking is just a Vim name for copying. The "c" letter was already usedfor the change operator, and "y" was still available. Calling thisoperator "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 命令也与标准剪切操作的作用一致。也就是说,该命令会先把指定文本复制到寄存器后再从文档中删掉。

……



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3