Emacs和Vim之间有什么实际的、客观的区别?例如,使用一个可以做而另一个不行(或者使用一个比另一个更容易做)?为了选择一门课程,我应该知道些什么?


对于我来说,选择使用emacs而不是vim的最大区别是emacs内置的gdb支持。Vim的默认发行版中并没有包含这个功能,而且用于集成gdb和Vim的项目几乎不可能使用MacVim

在日常层面上有巨大的区别——Vim(或任何vi变体)本质上是模态的(你进入命令模式,但你不能编辑),而Emacs(以及大多数其他编辑器)不是。

当然,使用菜单之类的东西,你不需要在Vim中实际进入命令模式——首先。但即使使用Vim的一小部分力量,你也会。这是Vim/Emacs争论的核心。

就我个人而言,我还认为Emacs的可扩展性要强得多。你可以找到很多东西的Elisp包。

不过,我很好奇,为什么您考虑学习其中一种而不是更传统的IDE。你为什么要学这个?

Vim不是一个壳。而且它不能很好地与子进程通信。这几乎是设计的,而在Emacs中,这些元素是设计包含的。这意味着有些东西,比如嵌入调试器或解释器(产生某种IDE),在Vim中是很困难的。

此外,Emacs快捷方式主要是通过修饰符访问的,显然Vim接口是出了名的模态接口,可以访问大量的直接键进行操作。

Emacs曾经是这两个编辑器中唯一可编程的编辑器,而Vim的可编程性有很多奇怪的级别,添加了Python和Ruby绑定(还有更多,我忘记了),Vim也可以以您所关心的大多数方式进行可编程。

我使用Vim,而且我对它相当满意。

Vim:

作为一个简单的编辑器更好(简单任务所需的键更少) 更活跃的脚本社区-内部语言:vimscript 一个集中的脚本、插件、配色方案…… 在python、ruby中也可扩展 可移植(emacs在这方面存在一些问题)

Emacs:

non modal by default (most of today's editors have taken this approach). Though there is evil-mode which emulates vim behavior. more powerful language for extending it (elisp is a full blown language, and in emacs you can practically redefine everything; while in vim you cannot redefine build in functions of the editor. On the downside, vimscript is relatively similar to today's dynamic languages while elisp doesn't resemble pretty much anything) more extendible excellent support for GNU tools (the bunch of them)

就我个人而言,我更喜欢vim——它很小,做了它应该做的事情,当我想要一个完整的IDE时,我打开它VS. Emacs的方法是一个编辑器,它想成为一个IDE(或者我应该说,一个操作系统),但并不完全,在我看来,过时了。以前有电子邮件客户端、ftp客户端、俄罗斯方块……一个包(emacs)中的东西是有意义的……如今,它不再是了。

然而,这两者都是程序员和超级用户社区用户之间的宗教讨论话题,在这方面,如果接触(在同一句话/问题中),两者都很适合开始激烈的战争。

Emacs具有Viper模式,因此在某种意义上,它提供了一个超特性集(除了那些在使用Viper和Vimpulse的Emacs中缺少哪些Vim特性?)

vi(和VIM IIRC)的重量较轻(它可以就地编辑文件),但提供的功能较少(子进程通信、扩展语言)。

对我来说,emacs的优点是,

tramp模式允许您通过ssh编辑远程文件。就像本地文件一样。 Tramp-mode + dired =全功能SFTP客户端 支持您需要的所有语言。 内置的终端模拟器(术语模式),所以我可以继续编码,而无需在应用程序之间切换。 可扩展性任何你不喜欢的东西都可以用lisp来改变。

Vim was always faster to start up than Emacs. I'm saying that on any machine, out-of-the-box installs of Vim will start up faster than out-of-the-box installs of Emacs. And I tend to think that after a moderate amount of customisation of either one, Vim will still start up faster than Emacs. After that, the other practical difference was Emacs' modes. They make your life tremendously easier when editing XML, C/C++/Java/whatever, LaTeX, and most popular languages you can think of. They make you want to keep the editor open for long sessions and work.

总而言之,我会说Vim让您使用它来完成简短、快速的编辑任务;而Emacs则鼓励您投入长时间的会话。

VI总是可用的,并且将在最残缺的、单用户模式、坏的图形、没有键图、慢的链接机器上运行——因此,仅仅为了系统管理任务,了解如何在它中编辑简单的文件是值得的。

Emacs是一个编辑器中的完整用户界面。其思想是在启动机器时启动Emacs,并且永远不要离开它。可能会有数千个会话。

与使用GUI编辑器/IDE和使用python/awk/等来完成额外任务相比,学习Emacs的功能是否值得,取决于你自己。

对我来说,emacs有更好的开发工具(不仅仅是基于标记的工具)。

Cedet(c/c++) Xrefactory(c/c++/java) 史莱姆(普通口齿) JDEE(java) 欧洲央行(代码浏览器) GDB 支持 NXML(xml)

我是一个不折不扣的Emacs迷,但我早在认识Emacs之前就认识VI了。也就是说,我让我所有的人学习VI,因为它总是可用的,在任何地方。选哪一个都不会错。

我从vi开始,到emacs,然后到vim。我一直想试试Emacs,看看在过去五年中发生了什么变化。(说到IDE,我已经使用eclipse有一段时间了,但我更喜欢我的终端窗口连接我的mac和我(丈夫的)linux盒子)。

剪切粘贴的事最近一直困扰着我。在Vim中剪切和粘贴比在Emacs和IIRC中需要更多的步骤。从浏览器粘贴到终端窗口很烦人,除非你做了一些我不喜欢做的奇特的事情,所以我忍受了奇怪的缩进。我认为,在emacs中编辑多个文件更容易。如果两个文件都在屏幕上,至少可以从一个文件跳转到下一个文件。

我没有使用vi或emacs的花哨特性,因为我只是想开始编码的工作。我所需要的是漂亮的颜色和适当的制表符到空格的转换(对python尤其重要)。

我认为这完全取决于你是想使用:wq还是Ctrl-x Ctrl-s (IIRC)来保存文件,如果你不关心花哨的东西。

@mgb是正确的。一两个月前,我曾在Debian发行版中使用最低限度的linux来修复一些东西。Vi是唯一可用的编辑器。

If you are looking for an objective analysis of both the editors, look at their origins and the philosophy behind their respective designs. Think, which one would suit you better and learn it (and learn it and learn it, because it takes time before you being to discover its true utility as against any IDE). An Introduction to Display Editing with Vi was written by Bill Joy and Mark Horton and he explains why he choose modal design and rationale for various key strokes ( it helps me to remember that CTRL-W +W (will switch to next Window and it will same for CTRL W+ CTRL W, just in case you held the CTRL key for a longer duration.

这里有一个Emacs时间轴的链接,并有对Multics Emacs论文的参考。这是一篇关于Emacs的RMS论文,我看到重点在可编程文本编辑器上(甚至早在1981年或更早的时候)。

我没有读过emacs的论文,但是读过Bill Joy的vi论文几次。 两者都是旧的,但你仍然会得到哲学,你可以选择使用当前的工具(vim 7。X还是emacs 25?)

编辑:我忘了说,阅读这两篇论文需要耐心和想象力,因为它会让你在阅读时回到过去。但这是值得的。

首先,Vi(原始实现)今天不使用。你说的是一些Vim推导。

要扩展Vim功能,必须重新编译Vim, Emacs则不必。

Emacs在self中有Vim (viper模式)。

Emacs通常需要手动安装,Vim通常预安装在所有Unix之类的操作系统上(但如果你有ssh访问主机的tramp模式win Vim:)。

如果你尝试Vim,那么你讨厌Emacs,所以先从Emacs开始。

也请阅读http://www.dina.dk/~abraham/religion/vi-tutorial.html(链接下拉,所以使用这个)

hxxp中的答案搜索://en.wikipedia.org/wiki/Editor_war

(以下文字是我的观点,不应被视为事实或侮辱)

With Emacs you are expected to have it open 24/7 and live inside the program, almost everything you do can be done from there. You write your own extensions, use it for note-taking, organization, games, programming, shell access, file access, listening to music, web browsing. It takes weeks and weeks till you will be happy with it and then you will learn new stuff all the time. You will be annoyed when you don't have access to it and constantly change your config. You won't be able to use other peoples emacs versions easily and it won't just be installed. It uses Lisp, which is great. You can make it into anything you want it to be. (anything, at all)

对于Vim,它几乎总是预先安装的。这是太快了。你打开一个文件做一个快速编辑,然后退出。如果您在其他人的机器上,则可以使用基本设置。它的可编辑性不是很好,但它仍然比大多数文本编辑器好得多。它能识别出你大部分时间是在阅读/编辑而不是打字,并使这部分工作更快。你的小指没有emacs症状。这并没有那么令人愤怒。这样更容易学。

即使我每天都在使用Emacs(而且喜欢它),除非你打算在你选择的程序上花费大量时间,否则我会选择vim

Seems an answer has been selected already, but the big difference to me has always been the modal vs. non-modal. Vim is modal, which means that it makes optimizations based on a specific set of usage modes. At least that's how I've always looked at it. This makes using Vim a different experience because instead of having a work area that you type code in, you really are telling an environment to act on the text. This is why people say things like with Vim you really are learning a language. The :wq and :s/foo/bar is all part of a shell like environment that edits and reads text.

Emacs on the other hand is much closer to most editors/word processors/etc. you see today. You have a workspace that has a highly programmable interface. That is why you see things like email, irc, shells, etc. As a programmer it is easy to think in terms of saying "take the line number I'm on and do something with the information". The desire to leave the editor becomes less because instead of having to quit, open some other app/language and do things on some text, you have Emacs where you can do these things within the scope of your editor.

这两种观点并不一定是对立的,只是它们揭示了两个不同的焦点。就我个人而言,我使用Emacs,但我见过非常了解Vim的人,他们可以诚实地说,选择哪种并不重要。我首先尝试了Vim,但Emacs最终支持了我。的确,无论您选择什么,您都应该至少在一定程度上精通Vim,因为它总是可用的。

如果您经常从一个站点移动到另一个站点,或者您的工作涉及到登录到生产系统,那么vim就是合适的选择。

默认情况下,所有*nix机器都会安装vi。

大多数sysdamins更喜欢ksh作为默认shell。KSH使用vi(或emacs)命令击键来搜索历史记录并编辑命令行。

如果你不太了解vi,当你登录到一个标准配置的unix机器上时,你就会受到严重的限制。

仅仅因为这个原因,我推荐vim作为你日常的编辑器。我曾经见过emacs爱好者试图在一个基本的unix服务器上修改配置文件。

在你的问题中,你没有提到你想让它用Lisp编程!但是当你评论你的回答时,我明白你实际上想要一个LISP编程接口。

对于这个精确的任务,忘记Vi吧。Emacs与LISP的集成非常棒!你应该使用SLIME。然后,您将与REPL进行出色的集成,能够将函数、缓冲区或文件直接计算到emacs缓冲区中运行的解释器中,以及更多…

击键执行::: Vi编辑将保留键入键的每个排列。这将在决策树中创建一个路径,该路径明确地标识任何命令,而Emacs命令是立即执行的键入键的组合,使用户可以选择是否使用命令。

内存使用和可定制性::: vi是一个更小更快的程序,自定义能力更有限,而Emacs启动时间更长,需要更多内存。然而,它是高度可定制的,并且包含大量的特性,因为它本质上是为文本编辑而设计的Lisp程序的执行环境。

Vim是一个方便的编辑器,你只需输入Vim的文件名来打开文件,编辑,保存和关闭。

Emacs是一个伪装成编辑器的“操作系统”,你可以评估代码来改变它的行为,并按你的喜好扩展它。在emacs上接收/发送电子邮件的模式类似于操作系统上的电子邮件软件。

当进行简单的编辑时,例如,修改配置文件,我使用vim。

否则,我永远不会离开emacs。

关于这两个编辑器,已经说了很多,但我只想补充我的5便士。这两个编辑器都很棒,你不会选错他们中的任何一个。

我使用vi/vim已经有15年了。我试过几次转换到emacs,但每次都发现vim实际上可以做缺少的事情,而不需要写一个lisp扩展或安装一些东西。

对我来说,编辑器的主要区别是vim让你使用环境/操作系统,而emacs试图封装它或替换它。 例如,您可以在文本中添加日期:r!日期在vim,或日历与:r!ccal1 2014,甚至用十六进制版本的内容替换缓冲区的内容。如。: % !Xxd,编辑十六进制,然后返回:%!XXD -r,以及许多其他用途,如内置grep, sed等。

另一个例子是使用jq和gron。如。将json blob粘贴到编辑器,然后运行转换:

:r!curl -s http://interesting/api/v1/get/stuff
:%!gron | grep 'interesting' | gron -u

OR

:%!jq .path.to.stuff

上面的每个管道命令都可以通过:%!<命令>,其中%表示所有文档,但也可以对选定的行等运行。这里gron输出可以作为jq路径。

您还可以获得EX批量编辑功能,例如。替换某些单词,重新格式化代码,转换dos->unix换行符,一次对100个文件运行宏。这很容易用ex完成。我不确定emacs是否有类似的东西。

换句话说,IMHO vim更接近unix哲学。它通常更简单、更小,但是如果您了解您的操作系统和工具,您可能只需要VIM提供的东西。我从来没有。

此外,vi在任何unix/linux系统上都是事实上的标准,为什么要学习使用两个做同样事情的工具呢?当然,有些系统提供mg或类似的东西,但肯定不是所有的。Unix + Vi <3。

好吧,只要我的5便士。

Emacs实际上更像是一个无所不能的程序,而vi(m)实际上只是一个编辑器。如果您正在编辑文本,它们都很好,但我更喜欢emacs,因为我必须将一个移出主行才能移动,并在命令模式中不断键入错误的内容。如果您没有这个问题,vi(m)可能是您的编辑器。

偏颇的观点:

Vi(不是vim)是一种专业需要。你总是有某种形式的 Vi容易获得,无论什么环境。你可以在vi中 在emacs中,您可以在vi中在unix-land中构建bash命令。

甚至Microsquish也必须支持vi(尽管他们做得很好 隐藏它),因为政府和公司遵守公布 标准。

在我看来,如果你在一个繁忙的环境中从事一份亲力亲为的工作——不 温室里的一朵花,被限制在一个开发项目的一个花哨的钻机上 环境,或者在学术界——了解一个高级编辑是一项工作 障碍。不要学习vim或emacs中的所有花哨技巧,不要 开发一堆宏,使编辑环境屈从于你的意愿。 这是一个巨大的时间消耗,当你注意的时候 不同的机器,你可能不能证明在工厂 环境。

读读比尔·乔伊的论文,他写得很好,甚至可以说 非常漂亮,编辑纯文本的工程练习 快。帕里托法则适用于此:80%的水果都在20%里 篮子的。编辑纯文本非常非常快是关键 编辑能力——其他都是可选的——有时是有害的。

这就像苹果和橘子。两者都有不同的设计和理念。Vim是一个文本编辑器,而Emacs是一个Lisp解释器,可以进行文本编辑。

我使用Vim是因为它快速、狡猾,而且非常擅长处理文本。它具有可组合的自然键绑定,可以使您的开发任务真正协调一致。Vim基于一种简单的*nix哲学,即做好一件事——即文本操作。

使用bash/zsh和tmux扩展Vim通常很简单,可以学到很多东西。恕我直言,这是一个很好的学习曲线。关键是要学习如何集成这些东西以获得更大的工作应用程序。使用Vim,您需要学习集成,因为除非您告诉它如何进行集成,否则它不会自然地进行集成。另一个值得我使用的扩展是Tig。它是一个基于ncurses的Git前端。我只是有一个绑定,它无声地打开Tig,然后我在那里做所有Git的事情。

由最终用户来决定什么是最好的。Emacs和Vim经受住了时间的考验,证明了它们的价值。最终,一个优秀的程序员只需要一支笔和一张纸就可以发挥创造力。好的算法不需要编辑器的支持。所以两种方法都试试,看看哪种方法能让你更有效率。从这两个软件中学习设计模式,因为有很多东西需要学习和发现!

我想引用《UNIX编程的艺术》一书中的一段话:

Many people who regularly use both vi and Emacs tend to use them for different things, and find it valuable to know both. In general, vi is best for small jobs – quick replies to mail, simple tweaks to system configuration, and the like. It is especially useful when you’re using a new system (or a remote one over a network) and don’t have your Emacs customization files handy. Emacs comes into its own for extended editing sessions in which you have to handle complex tasks, modify multiple files, and use results from other programs during the session. For programmers using X on their console (which is typical on modern Unixes), it’s normal to start up Emacs shortly after login time in a large window and leave it running forever, possibly visiting dozens of files and even running programs in multiple Emacs subwindows.

我在这里真正想强调的是:“许多人发现两者都知道是有价值的。

我认为主要的区别在于设计目标。 VIM是UNIX的工作编辑器。 Emacs是针对GNU和lisp黑客的,所以它有一些混合的设计元素。

我在我的工作站上使用vim,而我也喜欢emacs。

现在你甚至不需要考虑这两者之间的区别,因为Spacemacs。它是一个社区驱动的Emacs发行版。

正如它所说,

最好的编辑器既不是Emacs也不是vim,而是Emacs和vim。

Spacemacs结合了Emacs和Vim的优点,使您的生活和工作更加轻松。

请看下面的截图,

(来源:spacemacs.org)

Emacs的好处

Emacs has both non-modal interface (by default) and modal one (e.g. it can emulate vim and vi through Evil, Viper, or Vimpulse). One of the most ported computer programs. It runs in text mode and under graphical user interfaces on a wide variety of operating systems, including most Unix-like systems (Linux, the various BSDs, Solaris, AIX, IRIX, macOSetc.), MS-DOS, Microsoft Windows, AmigaOS, and OpenVMS. Unix systems, both free and proprietary, frequently provide Emacs bundled with the operating system. Emacs server architecture allows multiple clients to attach to the same Emacs instance and share the buffer list, kill ring, undo history and other state. Pervasive online help system with keybindings, functions and commands documented on the fly. Extensible and customizable Lisp programming language variant (Emacs Lisp), with features that include: A powerful and extensible file manager (dired), integrated debugger, and a large set of development and other tools. Having every command be an Emacs Lisp function enables commands to DWIM (Do What I Mean) by programmatically responding to past actions and document state. For example, a switch-or-split-window command could switch to another window if one exists, or create one if needed. This cuts down on the number of keystrokes and commands a user must remember. "An OS inside an OS". Emacs Lisp enables Emacs to be programmed far beyond editing features. Even a base install contains several dozen applications, including two web browsers, news readers, several mail agents, four IRC clients, a version of ELIZA, and a variety of games. All of these applications are available anywhere Emacs runs, with the same user interface and functionality. Starting with version 24, Emacs includes a package manager, making it easy to install additional applications including alternate web browsers, EMMS (Emacs Multimedia System), and more. Also available are numerous packages for programming, including some targeted at specific language/library combinations or coding styles.

vi类编辑器的好处

Edit commands are composable Vi has a modal interface (which Emacs can emulate) Historically, vi loads faster than Emacs. While deeply associated with UNIX tradition, it runs on all systems that can implement the standard C library, including UNIX, Linux, AmigaOS, DOS, Windows, Mac, BeOS, OpenVMS, IRIX, AIX, HP-UX, BSD and POSIX-compliant systems. Extensible and customizable through Vim script or APIs for interpreted languages such as Python, Ruby, Perl, and Lua Ubiquitous. Essentially all Unix and Unix-like systems come with vi (or a variant) built-in. Vi (and ex, but not vim) is specified in the POSIX standard. System rescue environments, embedded systems (notably those with busybox) and other constrained environments often include vi, but not emacs.

来源:https://en.wikipedia.org/wiki/Editor_war

我是Emacs的粉丝,但我鼓励其他开发人员学习VI,因为:

你可以使用VI编辑emacs的makefile文件。 VI包含ed命令,每个UNIX用户都应该知道ed和sed。

我注意到一些关于VIM启动速度比emacs快的评论。如果您真的关心这个问题,请在服务器模式下运行emacs,并将“emacs”别名为“emacsclient”。客户端速度非常快,因为它所做的一切都是轻拍服务器的肩膀,告诉它你想编辑哪个文件。在MacOSX上,emacsclient只有33K,而emacs是287M。

我不确定这些在现代硬件上是否有必要。在我的MacBook Pro (2013 Retina)上,当我从shell运行emacs时,它几乎是立即加载的。我丝毫没有察觉到停顿。当我运行Emacs时。app (GUI版本)可能需要3秒。

我听到的大多数关于emacs的抱怨似乎都来自那些对emacs不了解的人。我从1982年就开始使用vi和emacs了,我清楚地记得,在我早期的UNIX机器中,emacs加载速度比vi慢得多,并且占用了大部分物理内存,但现在已经不再是这样了,至少15-20年都没有了。

我承认的一个抱怨是“emacs小指”。在我年轻的时候,这从来没有困扰过我。现在我已经58岁了,我的小手指确实因为反复使用Control键进行emacs和弦而有点酸痛。在MacBook Pro的键盘上尤其如此,“控制”键向右移动了一个位置,为“fn”键腾出空间。当Control是左下角的键时,它几乎没有那么烦人。

我已经在生产/研究环境中使用spacemacs大约2年,neovim大约1年。Spacemacs是带有一些额外功能的emacs,比如图层等。neovim又是vim的一个分支,具有一些额外的特性。

就经验而言,我对他们俩都不太满意。我仍然在寻找一个长期的解决方案来满足我的文本编辑需求。

这里有一个简单的对比:

Neovim, vim, emacs, spacemacs, etc all of those editors consume less ressources compared to most of the editors out there. Neovim/vim is slightly faster than emacs, noticably faster than spacemacs. In terms of editing experience. I can easily say that emacs packages feel superior. I think that's because they blend in better with the core of emacs. Vimscript is nice and there are certainly great projects in the vim ecosystem as well. The good thing is they are better documented than most emacs projects I have seen so far. Both can be glitchy depending on the package you are using. Spacemacs tend to freeze, and neovim tend to display scary error messages, so pick your poison there. Modal editing in vim, is not an intuitive concept, but once you get used to it, you want it anywere. Both of the editor provide that.

我一开始是vim的用户,然后我切换到emacs,然后是vim,现在我又在尝试使用emacs。

两人都是伟大的编辑。 如今,两者都是可扩展的 两者都有很棒的插件和社区

作为开发人员,我们输入很多,最后对我来说,在缓冲区和文件中移动是最大的重复任务,所以我想要一个编辑器,我可以快速移动!

再次尝试emacs的动机是,我发现它的Ctrl键比vim更快,而且更容易推理。

在vim中,你有模式,你有插入模式,可视模式,正常模式,当你按下某个东西时会发生什么取决于你所处的模式,这是一种有状态的编辑方式。移动,进入插入模式,编辑,退出插入模式,然后再次移动。如果我错过了ESC按键或类似的东西,我经常会迷失自我。

在emacs中没有模式,基本上你用你的粉色按下Ctrl并键入按键,比如C-x C-f, C-x C-s, C-x C-c。有一些你需要释放ctrl键的键绑定,我讨厌这些键绑定,总是用按下control键的键绑定来替换它们。

我认为emacs方法更快地思考和输入,但是vim有另一个优点,那就是。它的命令是可组合的,它们通常有一个格式。例如,要删除一行,可以使用dd,删除一个单词dw。插件利用了这种感觉,使用vim-surround插件,你可以用ds”(delete surround)删除引号,删除到下一个/ dt/。删除之前的/:dT/,以此类推。所以只要你学会了移动的东西就会变得很有趣。

综上所述,今天我发现emacs键绑定在宏编辑方面更快,而vim命令在微编辑方面更强大

在过去的五年里,我一直在使用vim,所以我的编辑思想主要是关于单词、线条、周围环境、块等。删除这一行,删除引号,替换引号, 删除字在游标,我试图找到emacs移动为那

最后我想说的是,我更关心fzf而不是emacs或vim,我希望有一个完全基于fzf的编辑器