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


当前回答

偏颇的观点:

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

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

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

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

其他回答

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

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

关于这两个编辑器,已经说了很多,但我只想补充我的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便士。

我想引用《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.

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

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