简体   繁体   中英

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. 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.

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. 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.

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.

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. 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. 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. 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. 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. 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.

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.

There's no real reason to use nano. Pretty much anything is better.

As for vim and emacs, here's what I said last time this came up :

I'm semi-competent with vi keybindings, but I prefer Emacs overall. 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.

I'm only going to talk about Emacs' model because I understand it best. 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. 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). 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. An example is when I'm editing a Python module and need to add an import statement to the top of the file. The keystroke for going to the top of the buffer (Alt-<) sets the mark. I add the import statement. I press Ctrl-u Ctrl-Space and I'm back where i started. 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.)

The other (and more well-known) Emacs difference is the kill ring. 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). The essential feature is that subsequent yank commands retrieve older killed text. 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.

Emacs had these features in 1978. The only other major system to adopt them to any extent is NeXTStep (and now inherited by 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. Which is why, once you know how to use it, it's so hard to quit.

Vim rocks

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.

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. 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.

I've switched to IDE and gui editors many times but keep coming back to 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. I'm just using that as a complex-editing-task example.

Remarkably, vim seems to help fight RSI and leave your hands more relaxed. 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.

There are two things (roughly) that you get from using 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.

This is more specifically true when working in a unix environment, where plain text files are used for everything (code, scripting, config, processes,... etc).

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. 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.

emacs - and, I suppose, vim, maybe - have several advantages:

  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.
  4. Emacs never has to close unless you have to restart your computer or upgrade emacs. I usually run a single emacs process for weeks on end.
  5. Trivially easy to modify. I can bang out a highlighting mode for a DSL in a day, if I want. With indentation that more or less works. And I'm not even that good at 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.
  8. Runs everywhere I can access. Possibly some older IBM 390 systems might not run it...

I've used Visual Studio and eclipse somewhat. They are not as good at raw text editing as emacs. They are considerably slower and support less languages.

The only meaningful objection I hear raised in regards to emacs is "no intellisense". I don't use VS/Eclipse Intellisense when I do edit there. Further, the auto-complete mechanisms in emacs are superior, from what I can tell. (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.

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.

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. 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.

Vim has an enormous number of commands, and if those aren't sufficient for tasks you do repeatedly, you can define your own. 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). 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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