PDA

View Full Version : Emacs vs Vim




SuperMiguel
Jan 11, 2012, 11:21 AM
i have a 13" macbook air which text editor is easier to use? Emacs or Vim??



robbieduncan
Jan 11, 2012, 11:25 AM
This is basically a religious war that has been in progress ever since Emacs was first released. Expect carnage.

Obviously the answer is Emacs.

willieva
Jan 11, 2012, 11:46 AM
Each is a tool that has it's uses. There are things that emacs does better, and things that vim does better. Knowing both is a good thing. I develop software for a living, and use both on a daily basis.

Vim is pretty easy to get started with. Learning about 10 commands will let you do 95% of what you want to do. Emacs has a steeper learning curve, but IMHO gives more control for more complicated tasks.

If you're planning on doing any sysadmin type work, learn vim. It's great over a slow connection, and is pretty much guaranteed to be installed on any unix system you encounter.

Then go learn emacs.

mobilehaathi
Jan 11, 2012, 11:53 AM
Mega nerd war incoming.....


Learn both; use emacs!

subsonix
Jan 11, 2012, 01:02 PM
None of them are easy to use, with quite steep learning curve, comparatively IMO. The best thing you can do is try them for yourself. :D

maril1111
Jan 11, 2012, 01:09 PM
vim is easier to learn but i prefer emacs

ratsg
Jan 11, 2012, 01:36 PM
Neither, they both suck.

The fine people at Caldera/SCO have open sourced the original source code that you can download and compile. Source available here.

http://ex-vi.sourceforge.net/

As an alternative, the BSD people have a fine vi clone call nvi which is available here.

http://www.kotnet.org/~skimo/nvi/

subsonix
Jan 11, 2012, 01:41 PM
Neither, they both suck.

The fine people at Caldera/SCO have open sourced the original source code that you can download and compile. Source available here.

http://ex-vi.sourceforge.net/

As an alternative, the BSD people have a fine vi clone call nvi which is available here.

http://www.kotnet.org/~skimo/nvi/

But both vim and emacs are included in OS X.

talmy
Jan 11, 2012, 01:58 PM
Don't forget nano and ed, both come in OS X, ed being the oldest UNIX editor. I also maintain a free TECO (http://almy.us/teco.html) (TECO being about 45 years old) and there are plenty of other editors free and otherwise. My favorite is the EMACs-like, multi-platform Lugaru Epsilon. (http://lugaru.com)

rebby
Jan 11, 2012, 01:59 PM
This is basically a religious war that has been in progress ever since Emacs was first released. Expect carnage.

Obviously the answer is Vi.

Fixed it for ya.

firewood
Jan 11, 2012, 02:03 PM
Which ever one your fingers have already learned.

Both have steep learning curves, making both of them extremely difficult to use... at first. But that learning curve gets completely forgotten after one spends enough time with a particular edit key usage. How much time depends on each individual.

Having used vi for over a quarter century, I don't even notice my fingers typing vi edit commands, no matter how convoluted or poor UX/UI design that sequence is to learn. Exactly the same for long time emacs users.

jiminaus
Jan 11, 2012, 02:16 PM
I started with emacs because I didn't like the whole modal thing of vim. But now I use vim, because I (subjectively) find it more efficient to use.

However, can I point out that neither are good Mac OS X citizens. If your looking for a free Mac OS X editor, have you checked out Text Wrangler. It's free on the Mac App Store or downloadable from http://www.barebones.com/products/textwrangler/.

robvas
Jan 11, 2012, 02:17 PM
Neither.

TextMate, BBedit (or TextWrangler, the free 'lite' version), Komodo Edit, or SublimeEdit are all probably better choices.

You should know the basics of vi/vim but it takes a long time to be a wizard with it.

mobilehaathi
Jan 11, 2012, 02:18 PM
This should answer all your questions.

SuperMiguel
Jan 11, 2012, 10:22 PM
does the keyboard make a difference??? like how the macs keyboards are layed out?

also i been programming in VMs (not sure if one is better than the other in shortcuts)

and i don't know any of them.. been using nano for a while.. but want to start using Xemacs or vim

chrono1081
Jan 11, 2012, 10:50 PM
*makes popcorn to watch the nerd war about to unfold*

jiminaus
Jan 12, 2012, 12:21 AM
does the keyboard make a difference??? like how the macs keyboards are layed out?

Won't be a difference in either vim or emacs. They both assume a basic keyboard. For example, neither require the use of function keys, arrow keys or the editing block; although both can make use of them if they're available. So vim and emacs both work well with compact keyboards.

iEdd
Jan 12, 2012, 04:12 AM
Vim (or Vi if you prefer) is a great text editor. The majority of commands are single-key, so you don't destroy yourself reaching for things.

Emacs was designed to break your hands and wear out the escape key. :o
M-x tetris

Cromulent
Jan 12, 2012, 04:13 AM
I personally prefer Vim because when you start to learn some of the keyboard commands it quickly becomes one of the fastest text editors to use. With a little bit of effort memorising Vim cheat sheets you can quickly become extremely fast. In fact I really miss using Vim when I am forced to use Xcode as the keyboard shortcuts just seem so much slower to use.

iHutch105
Jan 12, 2012, 06:07 AM
Vim. For no other reason than familiarity (I use it every day at work).

willieva
Jan 12, 2012, 06:33 AM
The keyboard does make a difference. Emacs uses the ctrl key for many operations. On many keyboards it is easy to hold down the ctrl key with the palm of your hand while still typing. Not true of the current mac keyboards. This isn't a reason not to learn emacs, but it is a reason to get yourself a good keyboard for home use.

firestarter
Jan 12, 2012, 06:41 AM
Of the two, the correct answer has to be vi.

I think it's an essential to learn enough vi to be productive. Vi will always be there - and it'll work through pretty much any dumb terminal.

If I have to hack text or code on a Mac though, my tool of choice is TextMate.

seepel
Jan 12, 2012, 10:02 AM
I'm a vi user but I would actually recommend learning Emacs simply because the Mac text fields respond to a lot of the same short cuts. If this weren't true then I would totally say vi all the way.

talmy
Jan 12, 2012, 10:21 AM
The keyboard does make a difference. Emacs uses the ctrl key for many operations. On many keyboards it is easy to hold down the ctrl key with the palm of your hand while still typing. Not true of the current mac keyboards. This isn't a reason not to learn emacs, but it is a reason to get yourself a good keyboard for home use.

Which is why I assign the useless caps lock key to be a CTRL key. I also normally use a 23 year old Northgate Omnikey keyboard which has CTRL to the left of the A and also has an easily reachable ESC key for VI users.

Mac_Max
Jan 12, 2012, 12:36 PM
I use nano whenever I don't use a modern text editor. Nano doesn't have much of a learning curve and the amount of UI it does have is pretty good.

firewood
Jan 12, 2012, 02:10 PM
The tiny ESC key on the MBA 11 keyboard is just a bit harder to hit than might be desired for a vi user.

SuperMiguel
Jan 13, 2012, 12:32 PM
the professor uses Ubuntu and he uses XEmacs.. but cant seem to find any way of getting that install on OSX, will try port in a bit

thundersteele
Jan 13, 2012, 02:14 PM
the professor uses Ubuntu and he uses XEmacs.. but cant seem to find any way of getting that install on OSX, will try port in a bit

Aquaemacs

You can't install ubuntu on OSX. Ubuntu is an operating system. You can install ubuntu on a Mac though, or you can run a virtual machine inside OSX (virtualbox, vmware, parallels) and install Ubuntu on that virtual machine.

dmi
Jan 13, 2012, 02:42 PM
the professor uses Ubuntu and he uses XEmacs.. but cant seem to find any way of getting that install on OSX, will try port in a bit
XEmacs runs in OSX without Ubuntu

jiminaus
Jan 13, 2012, 03:09 PM
the professor uses Ubuntu and he uses XEmacs.. but cant seem to find any way of getting that install on OSX, will try port in a bit

If you're going to install emacs via port, you don't want xemacs, you want emacs-app.


emacs-app @23.3, Revision 4 (aqua, editors)

Description: GNU Emacs is a self-documenting, customizable, extensible real-time display editor. This is a port of the latest GNU Emacs source to the OpenStep (or NeXTstep) APIs, as implemented by Cocoa on OS X. It differs from Carbon ports of GNU Emacs in that it makes a more concerted attempt from the ground up to follow OS X desktop and UI conventions.
Homepage: http://www.gnu.org/software/emacs/
Library Dependencies: ncurses
Platforms: darwin
License: GPL-3+

Variants:
fullscreen: Add fullscreen patch
inline: Add inline patch from MacEmacsJP
jpfont: Add Japanese font patch from MacEmacsJP
patches: Add all patches: fullscreen, inline and jpfont * requires fullscreen inline jpfont
universal: Build for multiple architectures

SuperMiguel
Jan 13, 2012, 04:35 PM
If you're going to install emacs via port, you don't want xemacs, you want emacs-app.

well xemacs got installed and ran trough ports

but still not sure which one should i learn...

i mean i dont even know why i should learn one or the other... people just tell me to but dont tell me why... i been using nano for a while and it works fine.. so not sure why to switch

balamw
Jan 13, 2012, 04:46 PM
but still not sure which one should i learn...

Learn both.

vi is useful as you never know when you end up on a Unix system that doesn't support curses and you just have to edit some file.

emacs is better at IDE-like language support, but if you're on a Mac or Windows box there are better native solutions. (e.g. if I need to compare a couple of files and merge them, nothing beats emacs + ediff)!

Then, continue to use what makes you productive.

B

jiminaus
Jan 13, 2012, 04:56 PM
continue to use what makes you productive

This is the important point. For some, emacs is better because they're more productive in emacs. For some, vi is better because they're more productive in vi.

If there was a definitive answer that one is better than the other, then one would have faded off into history.

balamw
Jan 13, 2012, 05:08 PM
If there was a definitive answer that one is better than the other, then one would have faded off into history.

Nah, the butterflies (see xkcd strip posted above) would just keep recreating it. :p

B

chown33
Jan 13, 2012, 06:17 PM
i been using nano for a while and it works fine.. so not sure why to switch

If it works fine for you, then there is no reason to switch.

There's no reason to solve problems that don't exist. If you were having some problem with nano, such as you ended up on a Unix system that didn't have ncurses, then learning to use vi would be worthwhile. Or as an exercise in broadening your perspective, learning vi might be worthwhile. But as a problem that needs a solution, for you, there isn't a problem, so you already have the solution.

The most efficient software design possible is none at all.
The fastest and most bug-free code is the code you don't write.
The shortest learning curve is the one you don't have to go through.

SuperMiguel
Jan 13, 2012, 09:23 PM
If it works fine for you, then there is no reason to switch.

There's no reason to solve problems that don't exist. If you were having some problem with nano, such as you ended up on a Unix system that didn't have ncurses, then learning to use vi would be worthwhile. Or as an exercise in broadening your perspective, learning vi might be worthwhile. But as a problem that needs a solution, for you, there isn't a problem, so you already have the solution.

The most efficient software design possible is none at all.
The fastest and most bug-free code is the code you don't write.
The shortest learning curve is the one you don't have to go through.

Well if i didnt know car existed and ride a bike to school everyday... It takes me 6 hours to get there but i dont know any other way... People tell me to try a car but dont give a reason why i should.. No one tells me that i can go x mph and that i can get there in 40 min instead of 6 hours... Then if i can still make it there in 6h and been doing it for a long timee why fix a problem that dont exist???

Of course i would love a car... But i know to know what they are, and why they are faster??

robvas
Jan 13, 2012, 09:57 PM
You can do a lot of neat things with vim

http://www.youtube.com/watch?v=BPDoI7gflxM&list=PL9135DDC3477A316E

There are lots of plugins available to do all kinds of stuff:

http://www.youtube.com/watch?v=_galFWwSDt0&feature=related

Those two videos only scratch the surface.

seepel
Jan 14, 2012, 03:37 AM
I have to say, I'm quite surprised/pleased to see how civilized this thread has been. Kudos everyone!

pilotError
Jan 14, 2012, 09:41 AM
If your a professional, learn vi(m) as it is installed on just about every flavor of *nix out there. Nothing worse than being asked to check out a problem and not being able to edit a file. Doubly true if you use a hosting agent like Savvis where you can't get X Windows through the firewall.

If you just talking about your personal Mac, it really doesn't matter. Get a visual tool like TextMate or TextWrangler. Vi and emacs are both handy if your living life in the terminal.

If your a Sadist, use Ed the line editor.

AlanShutko
Jan 14, 2012, 10:12 AM
Vi and Emacs are both extremely powerful text editors that can make editing things a whole lot easier. If you're just changing a config file once in a while, nano is fine. If you're editing longer documents, or are programming, or need to process larger amounts of text, vi and Emacs both give you more powerful tools to do that.

Here's an example of something I did last week with Emacs. I sync my home directory between multiple computers, and some files keep conflicting because they're modified on both computers. To fix that, I loaded the log file into Emacs, used M-x keep-lines to keep only the lines of the log file that had the conflict filenames, and used a keyboard macro that I recorded on the spot to delete the extra log message text around the filename, and then convert the filename into the appropriate syntax to put into a plist to exclude a file. Elapsed time, about 5 minutes.

Vi and vim can both do very similar things. If you're programming, I'd really recommend learning a more powerful editor than nano. You could go for one of the mac-specific ones, which are certainly friendlier. I like the fact that both Emacs and vi are cross platform and I can use them on Unix, Windows, or Mac.

I'm a very experienced Emacs user (18 years) and a middling vi user, so I use vi for any minor quick edits to files, and Emacs for anything bigger. One bonus of both of these tools is that they've been around a long time and will continue to be around a long time. Time spent invested learning them will last you for years. Even with new IDEs coming out, most offer some level of Emacs or vi keybinding.

SuperMiguel
Jan 14, 2012, 12:35 PM
which one is easier to learn?

chown33
Jan 14, 2012, 12:56 PM
which one is easier to learn?

How would we know which one is easier for you to learn?

That's a serious question. Think about how you'd answer it. What have you told us about yourself and your experience that would let us know enough about you to answer the question?


In my experience, I think they're roughly the same in ease of learning. I reached about the same level of proficiency after a couple weeks of each. This doesn't mean everyone else will find the same thing.

What this really means is they both take dedication and practice in order to become proficient. And you will almost certainly need to become proficient in order to benefit greatly. Or you'll have to find recipes (macros) written by others, and I don't think there are vastly more macros for one editor or the other out there on the internetz.

At the moderate to advanced levels, they share similar principles, which is they're both languages dedicated to editing. In the same way, Forth and Lisp are both languages dedicated to programming, but I wouldn't say either one is easier to learn than the other. They have different strengths and weaknesses, different goals, and different logical syntax. They're also both perceived as quirky for casual reading and writing, but with very different quirks.

In the long run, I wouldn't pick a tool just because it's easier to learn. TextEdit is easy to learn, but there are more powerful programming editors with more powerful search & replace capabilities (to pick just one example feature). For example, Xcode's editor has regex, multi-file search, etc. TextWrangler also has a powerful search-and-replace. BBEdit is another. Yet they all are GUI-oriented editors using windows and mouse clicks for basic editing, the same as TextEdit. So in a sense, they are all just as easy to learn as TextEdit. It's only in the advanced capabilities that differences appear.

If you're trying to pick only one to learn, then flip a coin. Study the winner for one week. Work with it. Make it do things. Then switch to the other one and study it for a week. Make it do the same things you made the other do. Then decide for yourself which one you want to continue learning. Or switch back to the other for another week, and repeat.

McGiord
Jan 14, 2012, 01:01 PM
Wirelessly posted (Mozilla/5.0 (iPhone; CPU iPhone OS 5_0_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9A405 Safari/7534.48.3)

Mac Write

ThomasJL
Jan 14, 2012, 04:13 PM
Forgive me for my ignorance, but when I saw the title of this thread, I assumed that it may be about Apple's eMac desktop computers. :)

iEdd
Jan 14, 2012, 05:06 PM
which one is easier to learn?

Do the following:

- Open terminal
- Type vimtutor
- Go through the whole tutorial (couple of hours?)

- Type emacs
- Type C-h t (hold ctrl, press h, release both, then type t)
- Go through the tutorial

That will give you a feel for the basics of each one, and I think at that point, you will probably form your own opinion about which you prefer to use.

murrayE
Jan 15, 2012, 11:44 AM
Which is why I assign the useless caps lock key to be a CTRL key. I also normally use a 23 year old Northgate Omnikey keyboard which has CTRL to the left of the A and also has an easily reachable ESC key for VI users.
I used Northgate Omnikey keyboards for years with Windows PCs, and later essentially the same thing now branded as Avant Stellar, made by Creative Vision Technologies. And, having learned to type (as it was called back then, not "to keyboard") on a manual typewriter, I swore I'd only give up the manual feedback of such mechanical-switch keyboards when they were pried out of my cold, dead hands.

But then I junked my PC for an iMac with an Apple wireless keyboard last year, and I'll never go back!

I do agree with you that having the Ctrl key next to the 'A' is the sensible location. (It was one of IBM's several redesigns of their keyboards that forced everybody to follow suit.) But on the Mac, the Cmd key is essential. Where do you map that on your Omnikey?

SuperMiguel
Jan 16, 2012, 02:55 PM
Do the following:

- Open terminal
- Type vimtutor
- Go through the whole tutorial (couple of hours?)

- Type emacs
- Type C-h t (hold ctrl, press h, release both, then type t)
- Go through the tutorial

That will give you a feel for the basics of each one, and I think at that point, you will probably form your own opinion about which you prefer to use.

i did this for about 5-10 mins on each and atm vim seems alot easier/faster 1 key > 2 keys =)

talmy
Jan 16, 2012, 03:12 PM
I do agree with you that having the Ctrl key next to the 'A' is the sensible location. (It was one of IBM's several redesigns of their keyboards that forced everybody to follow suit.) But on the Mac, the Cmd key is essential. Where do you map that on your Omnikey?

The caps lock key on the Omnikey keyboard is mapped to the Cmd function. The caps lock key on the Omnikey keyboard is in the same location as the Cmd key on the Apple so it's easy to go back and forth between the Omnikey and the Apple keyboards (at least after I've mapped the caps lock key on the Apple keyboard to be Control).

I'll use my wireless Apple keyboard when I'm not doing heavy typing, but switch in the Omnikey for heavy work. I know I'm faster with the Omnikey. I've got a second Omnikey on my Window PC at work, and several more "spares" in the closet, although I've never needed one.

ratsg
Feb 17, 2012, 01:06 PM
But both vim and emacs are included in OS X.

And, IMHO, those both suck.

That is why I download/compile/install the original vi code and/or nvi.

If you like the built in editors, thats great. I don't, so I look to other options. That is what makes Unix great IMHO, choices.

subsonix
Feb 17, 2012, 04:50 PM
And, IMHO, those both suck.

That is why I download/compile/install the original vi code and/or nvi.

If you like the built in editors, thats great. I don't, so I look to other options. That is what makes Unix great IMHO, choices.

Don't you feel that you over exagerate a tad now? New vi, vi improved and the original vi is similar enough to be dealt with in the same vi editor reference I have here. The purpose of my post was intended for the OP who may not know better and download and compile from source just to try the editor. The original vi could apparently only deal with one open file at a time.