38

I am a quite happy user of Eclipse (I mostly develop in PHP and Python), however I found the answers to "What specific productivity gains does Vim/Emacs provide over GUI text editors?" interesting enough to make me wish to try out Vim or Emacs as well and see if they would turn out to be a better solution for me.

I have the general feeling that Vim and Emacs are not the kind of editor you learn by "playing with it" though. I have the impression you must dedicate some time and effort to "study" them a bit, before you can benefit from their power.

So, I have two questions for the community:

  1. In the linked thread responders have essentially answered by commenting on Vim (often mentioning: "I'm sure Emacs has the same"). Google trends seems to indicate Vim is the mostly adopted between the two, however my first question is: knowing that I have no prior experience whatsoever on any of the two, and that I use and develop (mostly PHP and Python) on GNU/Linux systems (Ubuntu, Arch Linux), is there any of the two which would represent a better option to start with? (To be clear: my question is not about the quality of the editors but it is about what it is strategically better to learn in my situation).

  2. What advice would you give me on how to learn using it/them? I know this is a broad question, but it is deliberately so. Have a look at this answer (unrelated topic) for an idea of the kind of information / style of answer I am looking for [but do not feel obliged to answer that way... any contribution will be welcome, in any form!]

EDIT (on picking the "accepted answer")

I picked one answer as the accepted one just now, but I would like to say "thank you" to all those who shared their experience and advice: almost all of it has being useful to me in some way. The thread has definitively exceeded my expectations! Thank you! :)

Community
  • 1
  • 1
mac
  • 42,153
  • 26
  • 121
  • 131

18 Answers18

34

I would advise that checking out both is worth the time because of various reasons already covered by other answers or "Emacs vs vim vs XY" threads.

Still if you would have to pick one of them I'd go with vim because of one thing:

Availability

Vi(m) has the advantage that it is installed (not only available) by default on almost any *nix system. So no matter whether it is your system or someone else's or whether you are allowed to make changes to it or not, your favorite text editor and friend is there waiting for you.

Once you know vi(m) it feels awesome in those situations where you ssh into a machine and need to do something with text (navigating through a file, editing, whatever). You are going to feel like a King. I remember several times when I almost freaked out because nano or pico were not installed and I had to use "this ugly beast vi" which made unpredictable things when I started typing (because I wasn't in insert mode and didn't even know what that was) and when I was happy to have googled that ":wq!" gets me back out of hell. Now I can look back and smile about it.

I have the general feeling that vim and emacs are not the kind of editor you learn by "playing with it" though

Vim and Emacs are certainly editors that you "learn by doing".

Of course the question cries for including these highly scientific text editor learning curve graphs =)

classical learning curves for some common text editors

Vim might be a bit harder in the beginning because its modal editing can feel quite unfamiliar at first. I think motivation is the key here. The article "Why, oh WHY, do those #?@! nutheads use vi?" explains the advantages quite well I think. In my opinion it really is worth to give it a try even while the learning curve might be steeper than with other editors and it sounds like you bring the necessary motivation.

Back to learning by doing.

Something I wish I would have done the first time:

Check out Vimtutor. It is an interactive tutorial which demonstrates the power of vim by showcasing it's basic commands and how they can be composed. Just type vimtutor in your terminal.

This helped me to really "get it" after trying to learn editing with vim several times in the past. The tutorial eases the learning curve dramatically as it explains the commands and makes you actually perform them so they become a habit. It really makes a difference compared to being frustrated because of feeling handicapped. Using vimtutor you also will see what the benefits of modal editing are and instead of fighting or ignoring it you are going to embrace it because you have experienced the advantages at first hand. I guess it would be pretty difficult to learn that all by oneself. So these 30 minutes are quite worth it.

Community
  • 1
  • 1
tosh
  • 5,222
  • 2
  • 28
  • 34
  • 5
    As an Emacs user, I don't like your conclusion, but can't fault the logic. Everyone who might ever touch a Unix box should learn vi at least enough to make simple edits and save out. Even if you are going to use emacs as your main editor, vi's simplicity and availability make it your go-to editor for making small config changes to unfamililar machines you might need to remote log into. – T.E.D. Apr 01 '11 at 17:56
  • @ T.E.D of course I agree that it is not a black and white world even though some people might think so. There is enough time to look into more than one editor. For example if you are OSX user some of the emacs commands like jumping to the beginning or end of a line and many others will work in every standard textbox and terminals with readline support. – tosh Apr 02 '11 at 07:34
14

I have the general feeling that vim and emacs are not the kind of editor you learn by "playing with it" though.

My experience with emacs is actually quite the opposite. I tried going through the tutorial, but it didn't seem to help much. The way I ultimately ended up learning is with a reference card and just forced myself to use emacs on my code until I got it correct*. Then again, I do also have a screw loose. Your milage may vary. Offer void where prohibited. You get the idea.

One other piece of advice I recall reading somewhere is to try writing down a list of about 10 commands you want to learn and keep it by you while coding. Once you've mastered those commands, make another list of 10 more. Keep doing this until you've got a big enough chunk of the editor committed to memory.

*Note that the linked reference card is out-of-date. If you google, you can get a more up-to-date reference card.

knowing that I have no prior experience whatsoever on any of the two, and that I use and develop (mostly PHP and Python) on GNU/linux systems (ubuntu, archlinux), is there any of the two which would represent a better option to start with?

I'm an emacs guy, so my opinion should be obvious. That said, you're likely best trying out the one that more people you know seem to use. Having someone who's experienced with emacs (and I'd assume vim) is a great help.

If you don't know anyone who uses either one, choose whichever one you feel is the prettiest or has the coolest name. You won't know enough to know which one you'll like, so you might as well choose arbitrarily.

Jason Baker
  • 192,085
  • 135
  • 376
  • 510
  • Completely agree. It's hard to go wrong with just using it for a project and having a reference card in case you get stuck. – Corey Porter Nov 28 '09 at 17:18
  • 2
    Second the idea of putting up a reference card in front of you and just start 'playing with' emacs. That is how I got familiar with emacs. – Raja Selvaraj Nov 30 '09 at 07:27
10

For vim try vimtutor

dimba
  • 26,717
  • 34
  • 141
  • 196
  • 4
    @everyone reading this answer and wondering what _vimtutor_ is: vimtutor is a command to insert in shell. See: http://gd.tuwien.ac.at/linuxcommand.org/man_pages/vimtutor1.html – mac Nov 28 '09 at 18:53
  • 1
    Yes - that's how I got introduced to vim. I takes less than an hour and it's very easy, so it's a very easy way to learn vim or at least try it. – Ray Hidayat Nov 30 '09 at 00:21
7

I came to Vim when I started using Linux after years of Windows development, and had to do a lot of work on remote systems via ssh. For the first couple of weeks hated it. After that I could not live without it.

Probably the best way to start is to use Vim in easy mode ([g]vim -y), most installations have a shortcut called evim. This runs vim in a mode that is in insert mode by default and remaps keys to the usual Windows ones (ctrl-S to save, ctrl-X to cut etc). You can then use it like a regular Windowsy editor but still access the power of Vim.

There is also Cream which is Vim + a bunch of scripts to make it behave even more like a Windows editor.

I started out using evim and Cream, but found I gradually transitioned to using 100% vim.

Also if you use gvim then most of the functionality is also available through the menus and you can see the keystrokes for the same functionality.

Also read the docs - there are extensive help files available on every aspect. I still browse them from time to time and find something new.

Dave Kirby
  • 25,806
  • 5
  • 67
  • 84
  • @Dave - I upvoted your answer too, as it does contain useful tips, but I would like to clarify that I am *not* a Windows user nor I have experience developing for that platform, so - unless by "Windows" you mean "eclipse" - bringing vim closer to Windows is not a plus for me. – mac Nov 28 '09 at 18:50
  • 2
    Even as an Emacs user, I second the opinion: anything that brings either editor "closer" to the Windows world, would be a backward move in my dictionary. – Escualo Nov 30 '09 at 02:28
  • By "Windows editor" I mean ones that use the Windows conventions for keyboard shortcuts and behaviour, which includes Eclipse and Linux editors such as Gedit. – Dave Kirby Nov 30 '09 at 08:59
4

Using VIM, I find the following quick reference card very helpful, especially for the stuff I don't do everyday: VIM QuickReference

For emacs, you should read the GNU Emacs Manual. Don't try to do everything all at once. Start with the basic stuff, and then move on to the more powerful features once you're comfortable with the easier stuff.

CBFraser
  • 435
  • 2
  • 8
  • Your suggestion to not try to do everything at once reminded me of a piece of advice I once got about learning emacs. Thanks! – Jason Baker Nov 28 '09 at 17:05
  • BTW, I like both editors, but I find emacs somewhat easier to program new functionality for, and vim is better when trying to edit remote files through a ssh connection. The worst, however, is trying to keep the commands for both in your head at once: stick with one first, and master it, before trying to learn the other one. – CBFraser Nov 28 '09 at 18:02
4

Some time ago I decided to learn vim beside Eclipse as well because of its powerful textual editing, search and navigation features. But - at the same time - I liked the project handling, code completion, refactoring and debugging features of Eclipse and I did not want to lose them.

Nowadays I use an Eclipse plugin called vrapper which provides me nearly all basic features of vim inside Eclipse without losing any Eclipse functionality. Of course it is not a full-featured vim but it gave me the productivity gain I 'expected' (motions, the dot operator, registers and marks). Also, this plugin can be considered the 'trial' version of vim where you can learn all basic and some advanced stuff within your 'best-known' environment.

There is another interesting approach called eclim. Eclim integrates Eclipse with vim from the vim side so you can use many features from Eclipse within vim.

For learning the basics of vim, this graphical cheatsheet helped me a lot.

Csaba_H
  • 8,215
  • 1
  • 41
  • 42
  • Many thanks for these two suggestions. Both of them are new to me and they seem something to definitively try, although I have to admit one of the reasons I am thinking of doing the switch is eclipse' huge resource footprint, and a plugin more surely doesn't make that smaller... – mac Nov 29 '09 at 13:34
  • Sounds to me like all he did was modify Eclipse and declare it vim. – Rob Dec 01 '09 at 00:04
3

I would go for Emacs. Explicit command name will makes your task easier. I switched to emacs after I had years of experience with vi and never looked back. Go with tutorial first. Hang out at #emacs in irc and people are happy to help you in real time, for whatever more you need.

aartist
  • 3,145
  • 3
  • 33
  • 31
2

My advice for learning emacs is to understand that everything is done by a command (written in elisp) that is connected (bound) to the key strokes that you make. The power of emacs comes from being able to write new commands and use commands that are not bound to keys (there are too many commands to bind each one to a command.) as well, of course, read and modify commands that are already in emacs.

Next learn how to use the Help key and how to make a key binding list, then how to search for relevant commands (apropos) and see if they are bound already.

Be ready to take learning diversions into the emacs manual (Help, Read manual, Emacs manual).

Don
  • 4,583
  • 1
  • 26
  • 33
2

One argument in favor of Vim if you know Python is that you can write Vim scripts in Python. See :h python. Emacs requires you to learn elisp.

I find myself gravitating toward Vim for scripting languages like Ruby/Perl/Python/PHP, and for Emacs for languages that are more interactive (Lisp, essentially). If you develop your Python code using an interactive Python shell a lot, Emacs might be good, because you can embed a Python shell right into Emacs. If you write code and run it from commandline a lot, Vim can handle that easily enough via :make or :!.

I really recommend you learn both and pick whichever you like better. They are both worth knowing.

Brian Carper
  • 71,150
  • 28
  • 166
  • 168
  • I'm agree with you about Vim being better for web developing, especially PHP and similar languages. – MortezaE Jun 05 '15 at 12:06
2

Wow, vi/vim vs emacs, what a temptation...

From a vi-user's perspective...

  • Always There
    vi is on about every unix system ever released, in the default install, and available for Win
  • May save you from RSI
    vi uses home-row keys for just about everything, modifiers like control and meta are used only for rarely invoked functions and even shift-key use is moderate. This was probably all just a lucky accident, but don't laugh at RSI. It can happen to anyone, it's seriously painful, it's potentially career-ending, and it's hard to treat.
  • Starts up instantly.
    In the past, this was a huge advantage over emacs. Emacs users had to start up just once, and navigate everywhere within emacs. Today it starts faster, but in vi, it's perfectly reasonable to quit out of it entirely on every compile or test cycle.
  • Has an awesome line-mode
    The line mode in vi is backwards compatible to the original Unix ed(1) program, an editor that had only a line mode. That is, vi's regular-expression-substitution-engine-/-line-editor was once an editor all by itself.
  • Easily scriptable
    Got something you want to do to every .whatever file in your project? It's easy to write a declarative script that will edit a sequence of files. No need for imperative or procedural programming.
  • Easily extensible
    Vim, at least, can be extended in Python.
DigitalRoss
  • 143,651
  • 25
  • 248
  • 329
2

First of all, be humble.

As long as you remain aware that they are very powerful tools you'll be ok. If you are finding a task very difficult, and you are thinking 'it's just me that sucks not the editor', you're in the right mind to learn and improve.

Bram's 7 habits are a good tenets to go by http://www.moolenaar.net/habits.html

Also I highly recommend having a go at writing a plugin. It doesn't matter what it does. It gives you the impetus to dive deep into the manuals.

michael
  • 11,667
  • 2
  • 26
  • 25
1

Maybe, a good way is to learn vim/emacs while using eclipse. Try vimplugin or emacsplus plugins for eclipse.

cetnar
  • 9,357
  • 2
  • 38
  • 45
1

This should really just be a comment, but against which answer ...

With Vim I'd suggest using the GUI version for a start, just dive in, the built-in help is excellent (:h and the screen splits adding a panel with comprehensive "hyperlinked" help pages). With vim the only potentially dangerous operation is a write, everything else you do is recoverable per command or edit (undo & redo).

The power acquired easily incentivises the learning.

Don Mackenzie
  • 7,953
  • 7
  • 31
  • 32
1

Here's the way you learn: Start typing. When you hit a point where you want to do something other than typing, look up how you do that. Repeat. It helps to start with a few basics, say 7 fundamental commands. Other than that, when you run into wanting to do some operation, look it up and use it.

Rob
  • 14,746
  • 28
  • 47
  • 65
  • Thanks 4 the advice. Maybe this really depends from one's learning styles, but that's not the way *I* learn this kind of things: for example I did not learn to OOP because I got to a point I felt I wanted to do something that I then discovered was called "OOP". I learnt OOP because I knew it existed, I researched a bit and said: "that's awesome! I will know what to use that for!". After having gone through half of the vimtutor, for example, I can already say that most of the cool vim features I learnt, I would not have discovered them driven by my own need. Again: learning styles, I suppose... – mac Dec 01 '09 at 00:43
1

This great Tutorial was a big help for me for my first steps in Vim. It is a gently introduction and explain at the same time the philosophy of vim in a pleasant way:

aByteOfVim

Jogusa
  • 5,530
  • 5
  • 24
  • 23
1

Don't get caught up in the vi(m) versus emacs religious war. They are both great editors. I originally started with VI (real VI not VIM) and later started using Emacs. These days, I tend to use both, but emacs more because emacs has some features I need which are not in vim.

The real challenge and what you should be aiming for is how to be as efficient, quick and accurate as possible with your editor of choice. Both VI and Emacs have a lot to offer in this respect. However, much of it boils down to two main habits you need to develop

  1. Don't use the mouse. Both editors were created when mice were not the plague they are now. When it comes to editing, cutting, pasting, highlighting etc, both editors offer keyboard equivalents. Use them and keep your fingers on the keyboard. You will be surprised how much faster you will become

  2. Avoid the arrow keys. This is for a similar reason. The arrow keys tend to make you move your hands off the main keyboard. In the end, this also slows you down and makes you less efficient. Both editors provide far more convenient functions which are faster.

These are the two main things to focus on when learning either of these editors. There is lots more, but to start with, just start with focusing on using the main keyboard.

After you have got that down pat, then begin to think about how you can tweak your environment to suit your needs. By this time, you will be familiar with the power of the editor you have chosen and will probably have some ideas. Both of these editors are very configurable. I find emacs is the most configurable, but you can easily get lost iin writing elisp to configure things and before you know it, your an elisp programmer who does a bit of PHP and Python. To some extent, the same can happen with VIM, but to a lesser degree. However, note that the defaults have usually been set by people with lots of experience and who probably know something you don't. Avoid making the mistake of trying to modify either editor to be what your use to. Learn how it works with minimal config first and then change once you have an idea of why it was done some way - know the rules before breaking them.

If your serious about programming, your editor will be your most important tool. Other important tools are your screen, your chair and your keyboard. The rest is incidental.

Tim X
  • 4,158
  • 1
  • 20
  • 26
1

The way I learned emacs was mostly by doing both of the following:

  1. All the GUI menus show you the key-bindings you can use to execute the same command as that menu item. Pay attention to the bindings for the menu items you select a lot, and try them out manually next time you get a chance.
  2. ctrl-h ctrl-h (think "Help! Help!") brings up a buffer that shows the various types of help available. If you then hit the "b" key (the buffer calls it "describe-bindings"), you will get a list of all the key bindings that are available in the buffer you are working on. Just peruse that every now and then with an eye for commands that look useful. Try them out when you get a chance.

As for vi, I learned it in the days before vim, so I pretty much had to use man vi to figure it out. Most of us emacs users will tell you that all the vi you need to know is :q! ("quit, and I really mean it"). :-)

But in truth if you are a Unix user you need to learn at least enough vi to do simple edits to config files and save them. You never know exactly what (if anything) you will get when you try to start emacs on a strange system Unix system, but vi is always there.

T.E.D.
  • 44,016
  • 10
  • 73
  • 134
1

Nearly everything you see or interact with in Emacs can tell you about itself -- you just need to know how to ask it.

To learn Emacs, learn about the current Emacs context: what the values of things are, what the relations between them are, how they are denoted, how you can change them or otherwise interact with them.

The most important thing to learn is that Emacs is Emacs Lisp -- it is a Lisp ecosystem. Learning Emacs means also learning Emacs Lisp -- the more you know, the better. Lisp is the most flexible and most powerful way in which Emacs realizes itself as "the self-documenting, extensible editor".

Icicles can help you learn Emacs and Emacs Lisp. It helps you ask Emacs about itself. This page gives an overview of the ways it does that: Emacs Newbie with Icicles.

Drew
  • 29,895
  • 7
  • 74
  • 104