鬼影剪切——为何“剪切与粘贴”功能在各处都已损坏
Ghost Cut – or why Cut and Paste is broken everywhere

原始链接: https://ishmael.textualize.io/blog/ghost-cut/

传统的“剪切和粘贴”存在根本缺陷:它缺乏原子级撤销功能,会导致文档排版错乱,并使剪贴板充斥着非预期的内容。为了解决这些问题,作者提出了一种名为“幽灵剪切”(Ghost Cut)的新机制,并在文本编辑器 Ishmael 中进行了实现。 在使用“幽灵剪切”时,按下“剪切”(Ctrl+X)并不会立即删除文本或将其移入剪贴板。相反,被选中的文本会变为“幽灵态”——即变暗并处于非活动状态,用户可以移动到目标位置,而无需担心文本消失或文档布局发生位移。一旦用户在目标位置执行“粘贴”(Ctrl+V),文本就会通过一次原子操作进行移动,且可以通过一步操作完全撤销。如果用户决定不进行粘贴,按下“Esc”键即可将文本恢复至原始状态。 这种方法在保留剪贴板以供正式复制使用的同时,将移动操作转变为一种安全且可逆的行为。作者主张在各文本编辑器中推广此功能,认为它消除了现有陈旧剪切粘贴标准所带来的认知负担和技术局限,从而提高了工作流效率。

这篇 Hacker News 的讨论批评了“Ghost Cut”这篇文章,该文章提出了一种替代传统“剪切并粘贴”操作的方法。作者建议将剪切的项目“幽灵化(ghosting)”而不是立即删除,旨在改善用户体验。 评论者对该提议持怀疑态度,原因如下: * **技术复杂性:** 用户指出剪贴板是系统级的共享状态;如果其他应用程序介入,试图“撤销”剪切或保持其状态可能会导致冲突。 * **肌肉记忆:** 许多人认为,破坏几十年来既定的界面惯例对于资深用户来说会造成困惑,且适得其反。 * **现有替代方案:** 几位贡献者指出,目前的功能(如拖放操作,或 Excel 和 Windows 文件资源管理器中现有的“剪切”行为)已经尝试过类似的工作流,但通常被认为不够直观或令人沮丧。 总的来说,社区赞赏这种重新审视基础用户界面假设的尝试,但大多认为所提出的解决方案弊大于利。
相关文章

原文

Cut & Paste is broken in every word processor, code editor, and browser text area you've ever used. And it has been that way for decades.

Just so we are on the same page: cut & paste is the combination of two operations: cut to remove the text from the document and place it in the clipboard, and paste to insert that text at a new point in the document.

How can it be broken if it is so ubiquitous? Let me list the ways!

1. Cut is undoable

The first flaw in cut & paste is that a cut can not be fully undone. Undo (control+z or command+z) after a cut restores the text to its pre-cut state in the document, but changes to the clipboard remain. If you regret replacing your clipboard contents then too bad, they have gone poof in the digital ether. Even if you use a clipboard manager, the undo has still not cleanly undone everything that one key did.

2. Cut reflows

The second flaw is that a cut reflows the document. A cut and paste is almost always for the purposes of moving text, and yet the instant I cut, the text reflows and I have to locate the point where I want to paste all over again. A tiny cognitive burden perhaps, but I'd argue an unnecessary one.

3. Cut & Paste is not atomic

The third and final flaw is that even though a cut and paste is conceptually an action which moves text from one place to another, it can't be undone as a single step (ignoring the clipboard issue for the moment). Undoing a paste will remove the newly added text, but it requires a second undo to completely restore the text—assuming there weren't any edits between the cut and paste. If there were intermediate edits, like creating a new paragraph, then that must be undone before we even get to the original cut.

Introducing Ghost Cut

I've added a mechanism to Ishmael that "fixes" these flaws. The good news is that it doesn't require retraining muscle memory or anything more than you are doing already.

I call it "Ghost Cut", and it works like this: pressing ctrl+x fades the selected text and makes it inert—you can't click on the cut text and the cursor just kind of leaps over it, but it is still present in the document. Nothing is placed in the clipboard at this point and there is nothing to undo. If you decide you don't want to paste then hitting escape will restore the text to its active editable state.

Pasting (usual control-V or command-V) removes the ghosted span from its original location and places it at the cursor, thus creating a single atomic move operation without the clipboard involved. In other words: it is completely reversable and can be undone in one stroke without poluting your clipboard.

Here it is in action:

Ghost Cut in Ishmael
Ghost cut in action

This is not without precedent. There are apps that do something similar, like Excel which fades cut cells, but I haven't seen this in a text editor.

Side effects

What if you want the original semantics of cut? Ghost cut makes that two keys rather than one: copy to clipboard (control-C or command-C) followed by Backspace to remove it from the original document. I so rarely use cut without paste, that this is a clear win for me.

Conclusion

I would be very happy to see all kinds of text-editors adopt this. The case isn't as strong with code editors admitedly. Code doesn't suffer from the reflow issue, but even so, if ghost cut existed for VSCode I could see myself working with it enabled.

联系我们 contact @ memedata.com