为什么像 Vim 和 Emacs 这样的老编辑器会在界面中暴露 File 和 Buffer 之间的区别?

发布于 2024-07-06 09:26:39 字数 304 浏览 5 评论 0原文

我的问题有意义吗? 使用 Vim 或 Emacs,您会了解到该界面公开了您正在缓冲区中编辑的文件状态的代码表示,该文件是您可以填充缓冲区或写入缓冲区的磁盘存储。 所有这些事情程序员都会知道,但是当只是编辑文本时,为什么它会暴露? 任何较新的编辑器都会告诉您“这是一个文件。编辑它。”

是的,我理解技术含义,但这不是我的问题。 这甚至不是一个这样做是否是个好主意的问题。 Vim 和 Emacs 是我们今天常用的两个最古老的编辑器,它们也有这种行为。 据我所知,没有新的编辑器能做同样的事情。 编辑们什么时候停止这样做了?为什么?

Does my question make sense? Using either Vim or Emacs, you come to understand that the interface exposes the code's representation of the state of the file you are editing in the buffer, the file is the on-disk storage you can fill a buffer from or write a buffer to. All these things a programmer would know, but when just editing text, why is it exposed? Any newer editor just tells you "Here is a file. Edit it."

Yes, I understand the technical meanings, but that isn't my question. This is a question not even about if it is a good idea to do it or not. Vim and Emacs are our two oldest editors in common use today, and they share this behavior. I know of no new editor that does the same. When did editors stop doing this and why?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(7

平生欢 2024-07-13 09:26:39

对于初学者来说,Emacs 使用大量不与任何文件关联的缓冲区。 每当您打开目录、阅读邮件、打开终端、编译程序、启动交互式 Python 会话或连接到数据库时,您都会获得一个缓冲区。 因此,Emacs 的基本工作单元是缓冲区而不是文件,同样的逻辑也适用于 Vim。

编辑文件的新应用程序没有区别,因为每个屏幕、窗口或选项卡都直接代表一个文件。 Emacs 和 Vim 等功能更强大的应用程序在这方面更加灵活。

For starters, Emacs uses plenty of buffers that aren't associated with any file. Any time you open a directory, read your mail, open a terminal, compile a program, launch an interactive Python session, or connect to a database, you get a buffer. Hence, Emacs's basic unit of work is a buffer and not a file, and the same logic holds for Vim.

New applications that only edit files make no distinction because every screen or window or tab directly represents a file. More capable applications like Emacs and Vim are a lot more flexible in that respect.

呆头 2024-07-13 09:26:39

好吧,这是我奇怪的哲学答案:

因为编辑器中的缓冲区和您正在处理的实际具体事物之间的后期绑定,为编辑环境提供了更大的灵活性和功能。

认为这已经过时了吗? 这个想法再次出现的一个地方是在浏览器中,标签和网页之间没有一一对应的关系。 相反,在每个选项卡内,您可以在多个页面之间向前和向后导航。 没有人会尝试创建一个 MDI 类型的 Web 界面,其中每个页面都有自己的内部窗口。 使用起来会非常繁琐。 它只是无法扩展。

就我个人而言,我认为 IDE 现在变得过于复杂,文档和缓冲区之间的静态绑定是其原因之一。 我预计在某些时候,当它们转向类似浏览器的选项卡式缓冲区模型时,将会取得突破,其中:

a)您将能够在同一缓冲区/选项卡中的多个文件之间进行超链接(并且将会有一个后退按钮等)

b)通用缓冲区将能够保存任何类型的数据:源代码、命令行、动态生成的图形输出、项目大纲等。

换句话说,很多Vim / Emacs 模型的一部分,只是进行了调整以更符合浏览器的发现。

OK, here's my weird philosophical answer :

because late binding between the buffer in the editor and the actual concrete thing you're working on, gives the editing environment more flexibility and power.

Think this is out of date? One place where the idea is back with a vengeance is in the browser, where you don't have 1-1 correspondence between tabs and web-pages. Instead, inside each tab you can navigate forwards and backwards between multiple pages. No-one would try to make an MDI type interface to the web, where each page had it's own inner window. It would be impossibly fiddly to use. It just wouldn't scale.

Personally, I think IDEs are getting way too complicated these days, and the static binding between documents and buffers is one reason for this. I expect at some point there'll be a breakthrough as they move to the browser-like tabbed-buffer model where :

a) you'll be able to hyperlink between multiple files within the same buffer/tab (and there'll be a back-button etc.)

b) the generic buffers will be able to hold any type of data : source-code, command-line, dynamically generated graphic output, project outline etc.

In other words, much of the Vim / Emacs model, except tweaked to be more in-line with discoveries that browsers are making.

丘比特射中我 2024-07-13 09:26:39

因为多个缓冲区可以向您显示同一文件的不同视图。 我不知道其他编辑器怎么样,但 Emacs 确实如此。 Old 到底是什么意思?

Because several buffers can show you different view of the same file. I do not know of other editors but this is true of Emacs. And what do you mean exactly with Old?

时光病人 2024-07-13 09:26:39

当应用程序开始被非极客大量使用时,他们不想为不相关的细节而烦恼。

When applications started becoming used heavily by non-geeks who didn't want to trouble themselves with irrelevant detail.

情绪 2024-07-13 09:26:39

我认为新编辑们放弃这样做是出于你所说的原因,因为它是一种抽象,只会造成阻碍。 而且大多数现代编辑器都有无限的撤消功能,因此“缓冲区”的概念有点隐含。

I think the new editors quit doing it for the reasons you stated, that it is an abstraction that just gets in the way. Also most modern editors have unlimited undo, so the idea of the "buffer" is sort of implicit.

有深☉意 2024-07-13 09:26:39

我想我只是一个老顽固(在顽固的 vim 阵营中),但是我使用的其他编辑软件包,例如 MS Word 或 Open Office,保留了我正在编辑的文件的副本和我正在编辑的文件的副本之间的区别。最后保存的版本。 这是非常无价的——我不想让编辑践踏我最后一个好的版本,直到我准备好这样做。 事实上,我有很大的机会(比如说千分之一)使用我正在编辑的缓冲区创建一个新文件。

另一方面,通过读取多个文件(同一文件的多个副本,或多个不同文件的副本)来创建文件映像的能力也很有用。 其他文档中也有隐约类似的设施。

所以,我可能没有抓住重点——我不知道你指的是哪些编辑来消除区别。 但我认为所有编辑器都会保留您正在编辑的文件副本与保存到磁盘的最后版本之间的区别。

I guess I'm just an old fogey (in the die-hard vim camp), but the other editing packages I use, such as MS Word or Open Office, preserve the distinction between the copy of the file that I'm editing and the last saved version. That is utterly invaluable -- I don't want the editor to trample over my last good version until I'm ready for it to do so. Indeed, there's a decent chance (say one in a thousand) that I'll create a new file with the buffer I'm editing on.

On the other hand, the ability to create a file image by reading multiple files (either several copies of the same file, or copies of several different files) is also useful. There are faintly similar facilities in other documents.

So, I could be missing the point - I don't know which editors you are referring to as removing the distinction. But I think that all editors preserve the distinction between the copy of the file that you're editing and the last version saved to disk.

独木成林 2024-07-13 09:26:39

因为这些编辑器的开发人员不关心向用户隐藏实现细节。

Because developers of those editors didn't care to hide implementation details from users.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文