简体   繁体   English

使用emacs,vim和nano之类的东西比任何其他IDE或文本编辑器有什么好处?

[英]What is the benefit of using things such as emacs, vim, and nano over any other IDE or text editor?

From what Ive seen. 从我所看到的。 emacs etc.. run in terminal. emacs等..在终端运行。 Is there any benefit to this? 这有什么好处吗? It seems that it would be more of a hassle to write and organize things. 编写和组织事情似乎更麻烦。 I'm not trying to be subjective I literally know nothing of emacs, vim, nano etc.. and would like to know more, maybe use one of them. 我并不是想要主观我对emacs,vim,nano等一无所知。想知道更多,也许使用其中之一。

Your question is a tough one. 你的问题很艰难。 Even if they do run in terminal, it's not their primary advantage. 即使他们确实在终端运行,这也不是他们的主要优势。 I'm talking about Emacs and Vim right now. 我现在正在谈论Emacs和Vim。 To be short, they've been around for at least 20 years (Vim) or more (Emacs), they have a pretty active community, they're scriptable so you can do pretty much anything with them if you know how and they're extremely powerful. 简而言之,他们已经存在至少20年(Vim)或更多(Emacs),他们有一个非常活跃的社区,他们是可编写脚本的,所以如果你知道如何和他们,你可以用它们做任何事情。非常强大。

They have a pretty big learning curve, so you'll probably end up fumbling around in them for weeks, if not months, before becoming proficient. 他们有一个相当大的学习曲线,所以你可能最终会在他们身上摸索数周,如果不是几个月,在变得精通之前。 The primary motivation for learning them is productivity. 学习它们的主要动机是生产力。 You can do some pretty amazing things in a minimal amount of keystrokes compared to, let's say, Notepad. 与Notepad相比,你可以用最少量的击键来做一些非常棒的事情。

Try one. 试试吧。 If you like it, stick with it for some time, endure the pain and then you'll see the benefits. 如果你喜欢它,坚持一段时间,忍受痛苦,然后你会看到好处。 It's almost like going to the gym. 这几乎就像去健身房。

Most people use IDEs nowadays. 现在大多数人都使用IDE。 They help with things that you can get through analysis of things you have already written. 他们帮助您分析已经编写的内容。 That stuff can be very useful and helpful, but they don't really help with the core task of actually editing code. 这些东西可能非常有用和有用,但它们并没有真正帮助实际编辑代码的核心任务。 What toolmakers are banking on is that those extra things provide enough of a benefit that it will outweigh how effective vim and emacs are as editors. 工具制造商所依赖的是,这些额外的东西提供了足够的好处,它将超过vim和emacs作为编辑者的效率。 They have pretty much won that battle in most communities, mostly because new developers faced with a choice between great code completion and refactoring support that is simple to use, and an editor that they won't see any benefits from for about 6 months go the easy way. 在大多数社区中,他们几乎赢得了这场战斗,主要是因为新开发人员面临着很好的代码完成和重构支持之间的选择,这种支持很容易使用,而且他们在大约6个月内看不到任何好处的编辑会去简单的方法。 I know I did. 我知道我做到了。

I am a vim guy now. 我现在是个男人。 Vim doesn't really seem to have the same upper bound of productivity, I have been using it for over a year and semi-regularly still run into things I didn't know about that make me faster. Vim似乎并没有真正具有同样的生产力上限,我已经使用它超过一年,而且经常会遇到一些我不知道的事情让我更快。 Even without that, the more I use it, the less thinking goes into what I am doing, which again, makes me faster. 即使没有它,我使用它越多,我正在做的事情的思考就越少,这再次使我更快。 Also, vim exists for every language and platform, and is installed on any UNIX server out of the box. 此外,vim适用于每种语言和平台,并且安装在任何开箱即用的UNIX服务器上。 It doesn't have any load screens, virtually leaps on to the screen, works fantastically with large files, and never slows down or crashes. 它没有任何负载屏幕,几乎跳到屏幕上,与大文件一起工作,并且永远不会减速或崩溃。 The skills that you learn with it will be applicable to everything you ever do for the rest of your career, as opposed to an IDE which will change when you change platforms. 您学习的技能将适用于您在职业生涯中所做的一切,而不是在您更换平台时会改变的IDE。

Vim is an investment, but if you are talking about something you will use for 8-10 hours a day for almost the rest of your life, learning curve becomes completely irrelevant. Vim是一项投资,但如果你正在谈论几乎每天都会使用8-10小时的事情,那么学习曲线就变得完全无关紧要了。

There's no real reason to use nano. 使用nano没有真正的理由。 Pretty much anything is better. 几乎任何东西都更好。

As for vim and emacs, here's what I said last time this came up : 至于vim和emacs,这就是我上次提到的内容:

I'm semi-competent with vi keybindings, but I prefer Emacs overall. 我对vi keybindings不称职,但我更喜欢整体Emacs。 The reason these editors have such fervent adherents is because the editing model they provide is more powerful than newer systems, which is why providing "vi keybindings" or "emacs keybindings" isn't enough, even if you aren't using any extension features or customizations for emacs or vi. 这些编辑拥有如此强烈的追随者的原因是因为他们提供的编辑模型比新系统更强大,这就是为什么提供“vi keybindings”或“emacs keybindings”是不够的,即使你没有使用任何扩展功能或emacs或vi的自定义。

I'm only going to talk about Emacs' model because I understand it best. 我只会谈谈Emacs的模型,因为我最了解它。 The common model for text editing today involves a buffer of text, in which text can be inserted, deleted, selected, and cut/copied/pasted to the system clipboard. 今天文本编辑的通用模型涉及文本缓冲区,其中可以插入,删除,选择和剪切/复制/粘贴文本到系统剪贴板。

Emacs buffers, of course, can support these operations. 当然,Emacs缓冲区可以支持这些操作。 Along with tracking cursor position for each window they're visible in, they also keep track of "marks" made in them. 除了跟踪每个窗口的光标位置,它们都可见,它们还跟踪其中的“标记”。 The text between the "point" (cursor position) and the "mark" is called the "region", and roughly corresponds to the selection in mainstream editors. “点”(光标位置)和“标记”之间的文本称为“区域”,大致对应于主流编辑器中的选择。

The difference is that Emacs keeps track of the last several locations the mark was set at in the mark ring, and you can return to them with a keystroke (or two, depending on your configuration). 不同之处在于Emacs会跟踪标记环中设置标记的最后几个位置,您可以通过击键(或两个,取决于您的配置)返回它们。 I find this extremely useful, especially since a lot of Emacs commands that change your location in the buffer set the mark at your old location. 我觉得这非常有用,特别是因为许多改变你在缓冲区中的位置的Emacs命令在旧位置设置了标记。 An example is when I'm editing a Python module and need to add an import statement to the top of the file. 一个例子是我在编辑Python模块时需要在文件顶部添加一个import语句。 The keystroke for going to the top of the buffer (Alt-<) sets the mark. 转到缓冲区顶部的按键(Alt- <)设置标记。 I add the import statement. 我添加了import语句。 I press Ctrl-u Ctrl-Space and I'm back where i started. 我按下Ctrl-u Ctrl-Space,然后我回到了我开始的地方。 I can keep doing this to cycle back to previous positions as well. 我可以继续这样做以循环回到以前的位置。 (Maybe I needed to select some text while adding that import statement.) (也许我需要在添加import语句时选择一些文本。)

The other (and more well-known) Emacs difference is the kill ring. 另一个(也是众所周知的)Emacs的区别在于杀戮戒指。 Most of the keystrokes for removing text from the buffer save text to the kill ring, which can then be recalled with the "yank" command (Ctrl-y). 用于从缓冲区中删除文本的大多数按键将文本保存到kill ring,然后可以使用“yank”命令(Ctrl-y)调用它。 The essential feature is that subsequent yank commands retrieve older killed text. 基本功能是随后的yank命令检索较旧的已删除文本。 So you can kill several sections of text in a row, then retrieve them in order. 因此,您可以连续删除几个文本部分,然后按顺序检索它们。 You can also cycle through the kill ring with Alt-y after a yank, removing the retrieved text and inserting the next entry in the ring. 你也可以在猛拉后用Alt-y循环杀死戒指,删除检索到的文本并在戒指中插入下一个条目。

Emacs had these features in 1978. The only other major system to adopt them to any extent is NeXTStep (and now inherited by Cocoa). Emacs在1978年拥有这些功能。在任何程度上采用它们的唯一其他主要系统是NeXTStep(现在由Cocoa继承)。 Other tools provide more features for specific tasks, can be extended in languages way easier to use than Emacs Lisp, and have nicer visual interfaces... but Emacs remains better at text editing. 其他工具为特定任务提供了更多功能,可以使用比Emacs Lisp更容易使用的语言扩展,并且具有更好的可视化界面......但Emacs在文本编辑方面仍然更好。 Which is why, once you know how to use it, it's so hard to quit. 这就是为什么,一旦你知道如何使用它,它就很难戒掉。

Vim rocks Vim岩石

Vim is harder to learn (you have to memorize the commands you want to use) but vastly more powerful than any IDE or GUI editor I've seen. Vim更难学(你必须记住你想要使用的命令),但比我见过的任何IDE或GUI编辑器都强大得多。

Part of the secret to vim is the line mode it inherited, ultimately, from the ed(1) text editor that was written by Ken Thompson himself. vim的部分秘诀是它继承的行模式 ,最终来自Ken Thompson自己编写的ed(1)文本编辑器。 It is remarkably powerful: it can be used for refactoring and even placed into scripts. 它非常强大:它可以用于重构,甚至可以放入脚本中。 It is based on regular expression pattern replacement. 它基于正则表达式模式替换。

And with all this power, because it's an old-school Terminal/xterm app, it's starts up instantly and never has a detectable lag. 拥有所有这些功能,因为它是一个老式的终端/ xterm应用程序,它立即启动,并且永远不会有可检测的延迟。

I've switched to IDE and gui editors many times but keep coming back to vim. 我已多次切换到IDE和gui编辑器,但继续回到vim。 I think this time I'll just stick with it and save myself the detour. 我想这次我会坚持下去,为自己省去迂回曲折。


Notes: 笔记:

If your IDE supports refactoring, that's a find reason to use the IDE. 如果您的IDE支持重构,那么找到使用IDE的理由。 I'm just using that as a complex-editing-task example. 我只是将它用作复杂的编辑任务示例。

Remarkably, vim seems to help fight RSI and leave your hands more relaxed. 值得注意的是,vim似乎有助于对抗RSI,让您的双手更放松。 The commands are unmodified keys, so you don't need to tense up your wrists holding down control or meta or command or bletch or whatever. 这些命令是未修改的键,所以你不需要紧张你的手腕按住控制或元或命令或bletch或其他什么。

There are two things (roughly) that you get from using VIM/Emacs: 使用VIM / Emacs可以获得两件事(大致):

  1. Customizability 可定制
  2. They run everywhere 他们到处跑

Both take an investment in time to learn. 两者都花时间学习。 But once you learn them using any other editor will feel inferior. 但是一旦你使用任何其他编辑器学习它们会觉得自卑。

Emacs and Vim are the most polished and multi-purpose software I can think about. Emacs和Vim是我能想到的最精美和多用途的软件。

This is more specifically true when working in a unix environment, where plain text files are used for everything (code, scripting, config, processes,... etc). 在unix环境中工作时尤其如此,其中纯文本文件用于所有内容(代码,脚本,配置,进程等)。

These tools takes some time to learn, even more to master, but then they can give you an unexpected productivity all day long. 这些工具需要一些时间来学习,甚至需要更多的掌握,但是它们可以整天为您提供意想不到的生产力。

I start using them both around 1990. Twenty years later, they are sill at the top of my list. 我在1990年左右开始使用它们。二十年后,它们位于我的列表顶部。 They are the first tools I install when I configure a machine and they can always bring me one step further when my current IDE is stuck... think about regexrename thousands of files, apply a complex reformatting of a text file, or any other text oriented task. 它们是我配置机器时安装的第一个工具,当我当前的IDE卡住时,它们总能让我更进一步......想想regexrename数千个文件,应用复杂的文本文件重新格式化,或任何其他文本导向任务。

emacs - and, I suppose, vim, maybe - have several advantages: emacs - 而且,我认为,vim,也许 - 有几个优点:

  1. More screen real estate. 更多屏幕房地产。
  2. Real Ultimate Extensibility 真正的终极可扩展性
  3. Minimal memory usage. 最小的内存使用量。 I've had over 100 files open, including multiple remote editing files, using under 35 MB of ram. 我打开了超过100个文件,包括多个远程编辑文件,使用35 MB以下的ram。
  4. Emacs never has to close unless you have to restart your computer or upgrade emacs. 除非必须重新启动计算机或升级emacs,否则Emacs永远不会关闭。 I usually run a single emacs process for weeks on end. 我通常会连续数周运行一个emacs流程。
  5. Trivially easy to modify. 简单易于修改。 I can bang out a highlighting mode for a DSL in a day, if I want. 如果我愿意的话,我可以在一天内敲响DSL的突出显示模式。 With indentation that more or less works. 随着缩进或多或少的工作。 And I'm not even that good at emacs. 我甚至不擅长emacs。
  6. Easier on the hands since you can remap keys easily to support your personal hand shape and preferred keyboard shape. 由于您可以轻松地重新映射按键以支持您的个人手形和首选键盘形状,因此手上更容易。
  7. Reliable. 可靠。 I might have forced an emacs crash once. 我可能曾经强行过一次emacs崩溃。
  8. Runs everywhere I can access. 我可以访问任何地方运行。 Possibly some older IBM 390 systems might not run it... 可能一些较旧的IBM 390系统可能无法运行它...

I've used Visual Studio and eclipse somewhat. 我有点使用Visual Studio和eclipse。 They are not as good at raw text editing as emacs. 他们在原始文本编辑方面不如emacs好。 They are considerably slower and support less languages. 它们相当慢,支持较少的语言。

The only meaningful objection I hear raised in regards to emacs is "no intellisense". 我听到的关于emacs的唯一有意义的反对意见是“没有intellisense”。 I don't use VS/Eclipse Intellisense when I do edit there. 我在那里编辑时不使用VS / Eclipse Intellisense。 Further, the auto-complete mechanisms in emacs are superior, from what I can tell. 此外,从我所知道的,emacs中的自动完成机制是优越的。 (eg, autocompleting variable names). (例如,自动填充变量名称)。

Of course, it does take a learning curve. 当然,它确实需要学习曲线。 For emacs, I'd judge 1 months of daily use will take you to the point of comfortable competency for everyday use. 对于emacs,我判断1个月的日常使用会带你到日常使用的舒适能力。

I use vi a lot (I'm using it now at work because I can't be bothered to start an xserver and because it's quick to start up), but only because I had to learn it (and by 'it' I mean a fairly small subset of commands) many years ago, it's useful for remotely editing files and sometimes gedit or whatever isn't available. 我经常使用vi(我现在正在使用它,因为我不能为启动一个xserver而烦恼,因为它很快启动),但这只是因为我必须学习它(并且'我'意思是'很多年前,它是一个相当小的命令子集,它对于远程编辑文件很有用,有时也可以用于gedit或其他任何不可用的文件。

Just for old times sake, I've just started emacs again to see how much I hate it and then I had to google for a cheatsheet to tell me how to close it. 只是为了旧时的缘故,我刚刚开始使用emacs来看我有多讨厌它,然后我不得不谷歌一张备忘单告诉我如何关闭它。 So I think it's fair to say it's not intuitive. 所以我认为说它不直观是公平的。

It's my opinion that it's a lot easier to think of yourself as Neo (Matrix) when working on a green on black terminal using arcane key combinations than to sit there using a friendly GUI. 我认为,当使用神秘的键组合在黑色终端上工作而不是使用友好的GUI坐在那里时,将自己想象为Neo(Matrix)要容易得多。

Vim has an enormous number of commands, and if those aren't sufficient for tasks you do repeatedly, you can define your own. Vim有大量的命令,如果这些命令不足以完成你重复执行的任务,你可以定义自己的命令。 But, you can use Vim effectively after you know only a very small number of those commands, so you don't have a huge amount to learn to get started (though you will fumble around for a few days). 但是,只有在知道这些命令的数量非常少的情况下才能有效地使用Vim,所以你没有足够的数量来学习如何开始(尽管你会在几天内摸索)。 You can also apply commands based on regular expression searches, which can be enormously handy if you want to apply a particular change to every line which meets some complex condition. 您还可以根据正则表达式搜索应用命令,如果要对满足某些复杂条件的每一行应用特定更改,这可能非常方便。 I can't imagine not coding in Vim these days. 我无法想象这些天不在 Vim编码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM