views:

1751

answers:

15

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! :)

+5  A: 

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
@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
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.
Arrieta
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
+4  A: 

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
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
BTW, I like both editors, but I find emacs somewhat easier to programnew 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
+9  A: 

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
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
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
+9  A: 

For vim try vimtutor

dimba
@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
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
+2  A: 

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
+3  A: 

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
+1  A: 

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
+1  A: 

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
+2  A: 

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
+14  A: 

1)

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.

2)

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 it's 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.

tosh
Thanks for this... I'm going to check out the article you linked in the next few hours.
mac
+3  A: 

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
+1 for mentioning eclim and taking into consideration that he is already familiar with eclipse.
tosh
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
Sounds to me like all he did was modify Eclipse and declare it vim.
Rob
+1  A: 

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

cetnar
+1  A: 

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
+1  A: 

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
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
+1  A: 

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