Hacker News new | past | comments | ask | show | jobs | submit login
Start Using Emacs – A Thorough Guide for Beginners (braveclojure.com)
299 points by nonrecursive on Sept 3, 2013 | hide | past | favorite | 137 comments



Emacs-related things I have learned recently:

* Sticky modifiers: I don't know why it took me so long for me to activate these. The difference between holding Ctrl while hitting another key or just hitting Ctrl once before the next key makes a huge difference for me. http://www.emacswiki.org/emacs/StickyModifiers

* Got an old-styled Thinkpad keyboard with the trackpoint buttons below the spacebar? I mapped the left button to C-x and the right one to M-x. These buttons are PERFECT for this purpose. I would have mapped them system-wide to Ctrl and Alt but didn't find a solution for doing that in Debian (console/tty).

* Helm: Incremental completion and selection narrowing. Makes it a lot easier to find those commands which you sort-of-remember-the-name-of: https://github.com/emacs-helm/helm

* Sunrise Commander: MC-ish file explorer, based on Emacs's Dired: http://www.emacswiki.org/emacs/Sunrise_Commander


I think you may also like key chord-mode: http://www.emacswiki.org/emacs/KeyChord


Seconded! Especially with magit (and I suppose with vc in general) key chords are really nice.



I had a look at god mode when it was posted in r/emacs and it looks neat. I'd choose it above sticky modifiers if it wasn't because I use evil which kind of supersedes (or more precisely, covers most of it) them


When I was in college I had the privilege to work on a project with a developer that understood emacs as on operating system and used it as a way of life. When we started the project he would yell at me whenever I took my hand off the keyboard and tried to use the mouse. Finally he started to hit my hand with a ruler when I would lift it up.

My emacs skills are still probably only 1% of his, but after working that short time with him I have never been able to fully feel comfortable using textmate or sublime text. I always come back to emacs, even though the learning curve even years later is still there. Just feels like the right tool to me.


> ... he would yell at me whenever I took my hand off the keyboard ...

> I always come back to emacs ... Just feels like the right tool to me.

Sounds like a mild case of Stockholm Syndrome... ;)


Fifty Shades of GNU?


Finally he started to hit my hand with a ruler when I would lift it up.

The Pai Mei school of teaching. http://www.youtube.com/watch?v=fCbf4DjlHuM#t=0m31s


hah! I did this to people too. I ended up popping the keycaps of the arrows off the keyboard and taping over the hole.


I don't know much about emacs, but that would be a good way to train yourself to use vim :)


On the first day of my first CS class in college, the gruff old professor passed around a stack of photocopied "VI TUTORIAL" papers. In the "MOVEMENT" section, it had pictures of arrow keys, then X's hand-drawn over top of each arrow key, and H J K L handwritten above their corresponding X'd out arrow keys.

Gruff old professor explained that using H J K L was the True and Proper Way and the arrow keys were a work of the Devil, so to make sure we were not tempted by the Dark Lord of cursor motion, he had the department's system administrator recompile vi on the department's (pathetically overworked) Sun to remove support for the arrow keys.

(As an aside, if you've never tried working interactively on a Unix box whose load is higher than its CPU speed in MHz, you've really missed out.)

Rather than get used to using H J K L, I spent that evening waiting for a new vi executable to build in my home directory.

Laziness will find a way.


> Rather than get used to using H J K L, I spent that evening waiting for a new vi executable to build in my home directory. >Laziness will find a way.

Doesn't sound like laziness as much as it sounds like the thinking of an obstinate youngster who secretly is uneasy with learning new things.


Was his name Mr. Miyagi?


Can I include this in the Emacs chapter? Please?


Chapter 8: The Cruel Tutelage of RMS.


Great work with this tutorial! It's a nice intro guide to Emacs.

One thing I'd recommend adding in the introduction is that even though Emacs can be daunting to learn in the beginning, the effort is worth it because it will eventually become your editor for everything, not just Clojure.

Have to start programming in a different language? Emacs is there for you. Want to write an e-mail message? Emacs is there for you. Want to keep a TODO list or a calendar? Emacs is there for you.

This fact was lost on me when I first started with Emacs many years ago. I had come from using "easier to use" editors like EditPlus and Visual Studio. After trying to use Emacs for a week, I gave up in frustration and didn't touch it for another year. I've been using Emacs for about 11 years since then and I think I wouldn't have dropped it if I had been told "I know it seems hard now, but it's extremely powerful and it can become your one program for everything, on any platform you will ever use".


Great feedback, thanks! I'll work it in.


I had tinkered with emacs over the years but mostly used vim for programming, until the past year or so when I started writing Haskell and LaTeX for school and put in a determined effort to use Emacs full time. I've found I like a 'regular' text editor more than vi's modes, and that (like rickdale's comment) when I've tried out other editors like Textmate or Sublime Text, they feel like they're missing something compared to the raw extensibility of Emacs. (What that something is I'm not quite sure and - I just feel like if I want an extensible editor, emacs is the best. Strong opinion weakly held I guess)

My advice to new users is to start simple and try to only add in extensions/modifications when you hit pain points. I added some universally useful/specific ones early on like AuCTeX, a solarized theme, turning on syntax highlighting, haskell-mode, and so on, but I've found that piling on a ton of plugins and getting away from the 'default' behavior makes it much harder to create a comfortable workflow. This is also why I'm not a fan of stuff like Prelude or emacs-starter-kit.


Have you tried evil? I mostly live in insert mode in emacs and when I need to do "something" I press Esc and do the magic


Interesting, I honestly was pretty confident no one who got used to modal editing ever wanted to go back to crazy key chording.


I think it depends on what people are using their editor for whether they'll jump ship. I started out on vim, and I really loved it. Then I was typing up papers using the vim latex suite and syntax highlighting would cause my machine to choke every time I scrolled through text. I could have just turned off syntax highlighting, but I tried emacs and auctex, and it worked wonderfully. Since then, I found a bunch of other things that I prefer about it, and only really use vim for quick config file edits. Now that I've been playing with it for a while, chords are second nature, just like modal editing became for me with vim.

I imagine that nobody who's terribly accustomed to either editor will switch unless they've got a specific need their current editor doesn't meet.


I had a similar experience, really. Do I want to use emacs to edit system files and such? Not really, I'll continue to use vim. But for programming projects and document writing I like emacs better. To be honest I think the thing that started it was messing with Sublime Text; after using it for a few weeks I started tinkering with emacs again and never looked back. I will say that I never fully bought into vim in terms of movement keys and in depth shortcuts; I pretty much used cursor keys and the mouse and didn't do anything too advanced.


I actually started using Emacs at work when work became dangerously boring and I was looking for a distraction. Plus I had read a lot about Emacs in my Vim days and wanted to know what it was all about.

So I suppose I actually switched without a specific need except for curiosity and boredom. I'm glad I did though, since Emacs has improved my life quite a bit since then.


I use both Vim and Emacs, and in most contexts Evil-Mode within Emacs that emulates most of Vim's vanilla functions.

Emacs also has modal editing that allows for per mode based keybindings.

Where Vim wins out though on the keybinding game is with its grammar that enables a great deal of mnemonics and the ability to bind keys based on key sequences that do not all have to be prefix keys except for the last key in the sequence, which is the case with Emacs currently.

That opens up a lot more options for generating terse keybinds that are simply not possible with the way Emacs binding system currently works, and coming from Vim I found the system extremely confusing until I read how Emacs keymaps lookups work in greater detail.

That spills over into what is possible with Evil-Mode bindings as well to a degree because of the prefix key requirement with the sequences.

And in Emacs, because of its keymap hierarchy system it is extremely easy to have custom keymaps shadowed and overruled by a higher ranking mode mapping, which again coming from Vim is not obvious what is happening there and how to overcome that behavior.

Even though I now grok how Emacs processes keymaps, I still much prefer Vim's system that allows for any key sequences to be interleaved to make very terse sequences.

The workaround to the situation with long chord sequences that use the Meta and Control keys is that I will bind the frequently used command to the hyper or super keys which are largely not used by modes nowadays and are much less crowded as a result.

There is no inherent reason why Emacs could not move towards a key sequence rather than a chord sequence binding scheme, so resolving the quagmire is at least tractable.

I do use Emacs chords where they are reasonable though rather than changing states just to interact with a REPL or a VCS mode, and in the context of working with Lisp I always use Emacs' chords as paredit obviates the need for any of Vim's grammar, which by default lacks a sexp object or ways of transposing objects well.


This is a great intro! I've been using Emacs since 1996 or so and I still learned a new key: M-m, which will go in my lexicon immediately.

BTW, "M-g g" (goto-line) is also bound to "M-g M-g" which I find much easier to type.

Another thing I discovered way too late about Emacs was the "q" key. When you're in a read-only buffer like a diff, a man page, an Emacs help page, or an info page, pressing "q" will bury the buffer and close the window (if it wasn't open before the buffer appeared). I find this tremendously useful.


> There are other options, like Aquamacs, which are supposed to make Emacs more "Mac-like", but they're problematic in the long run because they're set up so differently from standard Emacs that it's difficult to use the Emacs manual or follow along with tutorials.

Having used emacs on linux, windows and now mac I disagree with this - though aquamacs introduces some (annoying, to me) functionality, you can simply turn these off and it works just like emacs in any other environment.

I have found aquamacs works better with ansi-term + with full-screen functionality than vanilla emacs, and I use both these functions enough to not want to go back.


When you say vanilla emacs, do you include the Cocoa version? (http://emacsformacosx.com/)

I'm using that many hours every day and have zero problems.

Regarding fullscreen, if you use a recent build both native and non-native fullscreen are supported.


Yes, I tried the cocoa version and that's what I'm referring to. I recall having real issues in particular with ansi-term not having the environment correctly set + simply not being able to resolve that.

I'm pretty sure I had other issues too, but I can't remember them.

To be fair, I've not tried the cocoa version or any other for some time, so things may have changed.

However, I still think OP's point was unfair on aquamacs - other than some (annoying!) quirks regarding autofonts and tabs (I instantly turn those off), it's no different than emacs anywhere else, in my experience.


PATH, exec-path etc. are mangled because of the way OSX loads environment variables. Here's an Emacs package that fixes that:

https://github.com/purcell/exec-path-from-shell


+1 so funny, vanilla=cocoa...


I don't understand your reply. It is quite possible that somebody doesn't know that the Cocoa wrapper is a part of upstream emacs, which is why I asked.


I meant that I found it humorous that Cocoa (chocolate) was being described as "vanilla" on the platform. Purely language, not anything to do with the wrapper.


As an Emacs beginner and budding Clojure programmer in early 2012, I benefited greatly from Bozhidar Batsov's Emacs Prelude:

https://github.com/bbatsov/prelude

I highly recommend it, and have been very pleased to see it get better and better over the past year+.


And you shouldn't miss Bozhidar's blog on Emacs (http://emacsredux.com/) where he explains a lot of the very cool techniques he included in Prelude.


Finally an introduction that has screenshots which don't remind you of the 70's.

Fonts and color schemes do matter, specially nowadays with the likes of Sublime and Textmate. Even more so for new users.


This is one of the most beautiful theme I've come across, and the one I am currently using:

https://github.com/jasonm23/emacs-purple-haze-theme


Interestingly, I use Soothe (https://github.com/jasonm23/emacs-soothe-theme) also by the same guy, which is also one of the most beautiful themes to ever grace one of my editors.


Any reason why you guys chose these themes other than it looks nice? :)

Solarized seems to be the de facto theme these days. I always wanted a theme that had some kind of "science" behind it. It also looks pretty good.


Indeed, I used Soothe for a while too. Loved that as well.


If you want to preserve your vision, you probably want to change those colours. You need dark text on light background.


I started using emacs about seven years ago after about eight years of exclusively using vim, primarily because I wanted to see what the editor war's were all about (and because I got the blues from work and needed something uplifting...) I agree with the learning curve, and constantly am fine tuning my setup and configuration, but once you've mastered the basics, it truly becomes one of the most powerful editors. Plus it is constantly evolving (e.g., multiple cursors).

Another good emacs guide that I came across recently is:

http://m00natic.github.io/emacs/emacs-wiki.html

Additional resources I found helpful:

http://www.emacswiki.org/emacs/EmacsNiftyTricks

http://web.psung.name/emacstips/essential.html

Plus, check out the videos from Magnar Sveen's emacs rocks:

http://emacsrocks.com


After about a year developing a love/hate relationship with Vim I've finally had enough. After reading this post I think I'm ready to make the switch. Very good writing. Thanks for posting it.


I tend to switch back and forth between Vim and Emacs and am curious. What causes the hate in your relationship with Vim?


Vim is an excellent text editor. But I mostly use it for coding, and that's the problem. Vim is not an IDE. It relies on plugins to deliver a half baked IDE experience. Sometimes these plugins are broken and other times they refuse to play nice with each other. As I sort of need them to get the job done I end up wasting time fixing broken things instead of solving real problems. That's why I'm ready to throw this tool away and move on. I might try Vim again in the future when things are a little bit more stable. Anyhow, thanks for all the fish.


Can Emacs replace eclim (eclipse + vim) as a Java IDE? Are there plugins that can make editing Java in Emacs nicer and more productive?


Lots of people who code with VIM don't use IDE's out of choice though. And Vim has had 20+ years of development, so I don't think it's going to stabilize any more.


I'm fully in the vim camp. I think vim is a way better text editor and non-modal editing is terrible, but vim is must less extensible and vimscript is trash. Emacs + evil would be perfect if it didn't mean having to rewrite all the bindings for all the plugins to be more vim-like.


Install evil-mode and you can use all the vim movement shortcuts you're familiar with.


I've tried using emacs/slime with evil but currently I prefer vim/slimv. Evil just felt a little bit "off" compared to regular vim, or maybe it was the slime integration. Anyhow, I recommend giving slimv a try, there's a nice tutorial here: http://kovisoft.bitbucket.org/tutorial.html


I am a big Vim fan and promote its design for the most part, however with Lisp paredit and redshank covers text object movement, editing, and refactoring entirely so there is no benefit to using Evil-mode there once paredit and redshank is understood.

One downside though it that it will leave users wanting that in all languages, something which is sadly not available elsewhere as fluidly. I find myself thinking,"this is great, but what would really improve this situation is if it was inherently structured so that I could exploit that" in other contexts.


Maybe I should give emacs/slime another try then. I use paredit in vim already, but I guess I could give redshank a go. What I like in vim is shortcuts like "ca(" or "ci(" to change an s-expr or change the contents of an s-expr, or "da(" to delete an s-expr. And of course being able to use vim's other text editing commands and macro recording / replaying, visual mode etc.


Seriously what someone needs to do is write Vim in Lisp to put an end to these dilemmas.


Don't do it. Chants VI VI VI.


Irrespective of the merits of emacs itself, this feels like a nearly perfect introductory tutorial. I've never seriousny used emacs, but this made me want to go try it and made me feel like I would probably succeed. Good show, whoever wrote this.


Thank you!


I also recently started using Emacs. Not much progress in learning, yet, though.

It would be nice if someone made a nice starting package that would set it up more sanely for all the IDE-oriented people (basically take what modern IDE can do out of the box and setup Emacs that way). Something similar to what Ubuntu did for Linux. I have seen lots of personal configs on Github, and read lots of Emacs Wiki on how to set this and that, but it's still quite a struggle for me. Part of the struggle is that there are too many options sometimes.

Maybe someone will have a good suggestion regarding this.

Edit: Someone mentioned Prelude, didn't know about it. That looks good, like something I wanted.


The starter packages like prelude and emacs-starter-kit are more like a learning to walk with a crutch when you have perfectly working legs. They offer an easy way to start but once you start using them you'll find it hard to do it the normal way (like when you need to modify your emacs config or add some new elisp that isn't included).

It is better just to start emacs do C-h t and start learning, then add and configure when needed. You'll need to start out rough but after a while you'll learn how emacs works and be a better emacs user because of it.

Though if you don't invest in emacs and just need it to finish your thesis or because a professor won't let you use anything else then the starter kits could be fine as they are pre-configured.


I might be biased (I'm the author), but I don't think that emacs-starter-kit prevents you from doing things the normal way. You can still modify your emacs config and include vendor elisp, and ESK doesn't make it more difficult.

And with the tutorial - I have a pretty low opinion of it. I mean, it starts out talking about how to navigate up and down one screen - who cares about that when they're starting to learn a new editor? Who? Emacs already has a reputation for being obscure and difficult, and the tutorial does not help.

This frustration isn't directed at you, of course - I appreciate the comment. In general, though, I think that Emacs instructions would be better if they had a little more empathy for the learner. As a new person, I don't care about hearing all this magical stuff about emacs right off the bat - I can't even make sense of it because I have no context. Just show me how to actually do real work.


Yes, original tutorial and Emacs configuration is a bit obscure, for historical reasons. That's understandable.

Another thing I struggled with was some hints how to actually write and structure your own configuration files. For example, is it good to use the configuration inside Emacs? Where this section should go into the config? I had issues figuring out how to load packages etc. In what order should configuration be specified? What if I use multiple computers, can I share parts of configuration? Etc.

Similar for keybindings. What keybinding can I use for my private stuff that are unlikely to conflict with other things?


That was kind of my point about the rough start, you won't get emacs to do the real work without putting time into figuring out how to get it to go.

The tutorial is more of a get you started and make sure you can actually edit text in emacs.

The most important parts of the tutorial are the how to save (which most people get to) and getting more help which is probably what people don't get to or understand. It isn't the best thing but it is okay if people make it through the end.

But you're right if you don't want to mess with your editor and `learn` emacs go for a starter kit or go for another editor with bells and whistles included.


"That was kind of my point about the rough start, you won't get emacs to do the real work without putting time into figuring out how to get it to go."

I disagree. It's not true for most IDEs, why should it hold for Emacs? This argument was also raised about Linux, but then Ubuntu came along and proved it was wrong. This seems to me like a religious stupidity - you have to use it for everything or it won't work at all.

My main motivation to use Emacs is org-mode and Common Lisp. That's already real work; although I try to use Emacs for everything, but using it for just one of these things would be perfectly valid use case for many people.

It's not that I wouldn't like to mess with the editor either; in fact I did a lot. But it still was not enough for it to work decently. I will have to try one of the starter packages yet (probably Prelude), though.


I don't have problem with Elisp. That's actually lot easier than what IDEs offer as a way of customization (Java?), and that's one reason I am interested in Emacs :-). What I don't like is the transition period where I am not set up properly. It doesn't quite feel like learning, but rather reinventing the wheel.

And I don't have big requirements either - I just need some sort of project management (being able to work with multiple files), grep, diff, syntax highlight, ability to indent/unindent and comment/uncomment block on a hotkey, more sane undo and maybe a little bit of completion and language documentation integration.

I can program in Notepad++ and be happy. So if it would be configured to do what that is doing out of the box, great.

Another problem I have, when I want to rebind a key, how do I figure out what keys are used and in what modes? Is there a way for the system to give me a suggestion for a key?


Invoking the help system by typing C-h b (the command "describe-bindings") will open a new buffer showing all the keybindings in effect in the current buffer. Picking an unused binding to your liking is a matter of scanning the list.

The Emacs help system is a marvel and an astonishment. It's the second thing to explore after running the built-in tutorial. And it's the first thing to master.

Don't neglect the hyperlinked, highly navigable Info Manuals, which you read right within Emacs. They are among the most literate technical documentation I've ever read.


Yes, I am aware of all that. Still, there can be various modes in effect, so it would be nice to have a function that would do a pick (that would work in all modes) instead of me scanning the list all the times.

Also, it would be nice if I could easily remap all keys with the given prefix. Maybe someone wrote library for these things already, I don't know.


C-h b - describe the key bindings for the current binding

C-h f - describe a function

C-h k - describe a key binding

The help system in Emacs is wonderful.


> The help system in Emacs is wonderful.

Agreed. Plus the often maligned GNU info is actually good when you're browsing from within emacs.

More good help:

C-h i - Browse GNU info

C-h m - "describe-mode": Gives keybindings and help for the current major mode and all the active minor modes.


I started following along with Avdi Grimm as he rebooted his .emacs a while back, and it has been tremendously worthwhile. I am very glad I adopted his technique of splitting up my .emacs into multiple smaller files, and using packages in emacs24 has cleaned up things even further.

http://devblog.avdi.org/category/emacs-reboot/


IDE's tend to be language specific while emacs tries to be agnostic. There are certainly options that could make your emacs a language specific IDE, for instance, look at emacs-live if you are doing clojure development.


I tried to get into Emacs on OS X a few times, but one of the things I don't like is the awkwardness of not having the Meta key mapped to a direct simple key press.

Activating the "Use option as meta key" isn't a good solution because I sometimes need to type accented characters that require the option key.

How do people deal with this when using Emacs in the OS X Terminal app?


I use cmd for meta, there is an option for that:

    (setq mac-option-modifier nil
          mac-command-modifier 'meta)


I'll have to try that. Is this with the regular emacs in the Terminal app? Does it interfere with shortcuts like Cmd-N to open a new Terminal window?


That config is not for terminal Emacs. It's only for when you are running a native cocoa Emacs (like http://emacsformacosx.com). For terminal I always enable option as the meta key and use the OS Character viewer for the rare times I need to type a unicode character into the terminal.

Having option as meta is useful outside of Emacs, as "bash" (and other shells) use Emacs keys by default (M-d, M-f and M-b are all essential for me when I'm using bash).

I wish the OS would let me use the Fn key for doing fancy unicode characters (maybe Fn+option or something)—that way I could have good unicode input and my precious meta key.


I use https://github.com/andymcd/cmd-key-happy which swaps option and command, and which lets you whitelist keys (iirc Cmd-N is among the defaults) to be exempt from that swapping.


Iterm2 will let you swap option and command. I also cheat and use Keyboard Maestro to UN-swap Cmd-Tab and Cmd-` so that application switching and window switching still works.


You can enter accented characters into emacs by hitting M-x 8:

  M-x 8 ` e -> è
  M-x 8 / a -> å
  M-x 8 E   -> €
The number of these binds does not cover all of unicode, but it's surprisingly high nonetheless. If your desired character does not have a direct bind like that, or you just can't find one (C-h b lists them), you can insert a character by hitting M-x 8 RET and then typing its name:

  M-x 8 RET "Em dash" -> —
  M-x 8 RET "Hebrew letter double vav" -> װ
Tab completion works for these, of course.

[edit] I just saw the comment where you're more specific about what you're looking for. This isn't it, but having gotten a reply already, I don't want to delete this comment. It won't help you, but maybe it will others :P


It's C-x 8, not M-x 8. Use C-x 8 C-h for help


Uhh, whoops! I can't believe that I messed that up. Sorry!


Years later, I am still learning new things about emacs regularly.


http://lmgtfy.com/?q=typing+special+characters+into+emacs ;-)

I've used Option as Meta for years (been using Emacs since (gulp) 1977 on ITS/TOPS-20) and never had any trouble. You can use the M-x insert-char (M-x ucs-insert) and type in the code point or Unicode name of any character.


I should have explained better: I want to type the accented characters the same way I type them into other OS X text fields, and not in a non-standard, emacs-specific way.

I want to hold down the option key and press another key to get the character I need. That's why using Terminal's all-or-nothing option of mapping option to meta doesn't work.


iTerm supports using just one option key as meta. But in general I prefer using a build of emacs with Cocoa support enabled (you can get them at http://emacsformacosx.com/)

That lets you set up things like you want with M-x customize-group ns

I'm using CMD as meta there and CTRL as control, option stays option.


I use Caps-lock as control and Command as meta. Has worked great for me.


I'm always curious why people remap the caps lock to be control. For me, extending my pinky to the caps lock makes the second key press hard. Like quitting emacs would be harder for me. I should make command the meta key though. That seems super beneficial


I use the 'use option as meta' heavily and haven't till date needed to type accented chars. Maybe you can try to use only the left option as a meta and leave the right one for accented chars? Not sure whether the Terminal.app supports it, better chances of iTerm supporting it though.


Unfortunately the option-as-meta setting applies to both left and right option keys.


One workaround could be to install Evil-mode so you can use Vim bindings in Emacs. Vim, and thus Evil, doesn't use Meta in any of its mappings. Though you'll still need a way to type Meta for some Emacs-mode-specific mappings.


Question to the Emacs crowd: how do I hit Alt comfortably? My instinct is to use my left ring finger, but have trouble doing that without moving my other fingers much. Could it be because I have very large hands (or because my keyboard sucks)? Is it a good idea to just remap capslock to be the meta key?


The control key is used more often than the meta key, so I'd reserve that choice bit of keyboard real estate (caps-lock) for control. For meta you can hit Esc, or even easier Ctrl+[ which is the same thing. Contorting your hand to hit control and alt in their default locations is going to cause you pain, so don't do it.

I now use a kinesis keyboard, which has two giant thumb keys for your left hand, I use those for control and meta. Before that I used control at caps-lock and meta using Ctrl+[, which worked well and pain-free for me for years.


I use my thumb.

Though I replaced my CAPSLOCK with CTRL and I mapped C-x C-m and C-c C-m to be equivalent to M-x. This dramatically reduce my usage of Alt.


I tend to use my left thumb. Seems to be close enough on PC and Mac keyboards that muscle memory works fine.


On OSX I have Meta bound to the Apple key.

What also helped is a tip borrowed from Steve Yegge [1] to bind C-x C-m to M-x (also C-c C-m, in case you miss the x). This avoids my most common use of Meta, allowing me to use the more comfortable Control (bound to Caps Lock).

[1] https://sites.google.com/site/steveyegge2/effective-emacs


Having two control keys is really useful because then you can alternate hands. My layout looks like this:

[super] - [left meta] - [left control] - [space] - [right control] - [right meta]

Having control and meta right next to each other also makes C-M-* combinations easier to reach.


I just realized that I use my thumb for that.


Emacs makes Windows more bearable - thats why I'm thinking of returning.


> Go ahead and undo that change.

How do I do that?

Thanks for the guide by the way!


C-_ is undo in Emacs. That's hold Control, and press "underscore". On my keyboard (most keyboards?) this requires holding Shift and pressing the "minus" key. Hopefully that's clear.


C-/ is also undo, which is arguably easier to reach :)


Or C-x u


I'm learning Emacs for class, and I was wondering: do you use the same hand to hit the command/meta keys? For example, when I'm doing C-n or C-p, I am currently hitting the command key with my left hand, but the identifier with my right. Is this the normal way, or do most people use one hand to execute a command?


I believe the general ergonomic advice is to hit the modifier and "normal" key each with a different hand, so you're doing it right. I try to follow that guideline, but I frequently make exceptions. This is especially true since I have caps lock mapped to ctrl, so I favor that left ctrl button regardless of the other keys I'm pressing.


So for C-x, I should hit the command key with my right hand?


First off, the Mac "Command key" is not involved with "C-x". "C" is for "control". "Command" is often bound to the Emacs "Meta" key, which would be "M-x".

For C-x I generally hit Control with my left pinky and X with my left middle finger: since C-x is a "prefix" key, there's going to be another key I hit later and that will generally be hit with my left index finger.

However for the C-x C-s sequence I use my left index finger on X and my left middle finger for S. Same with C-x C-q.

For M-x I use my left thumb on the Meta key (my Mac's "Option" key in my case) and my left index finger on X.

Just like playing piano, there is no "right" way to map your fingers to the keys (everyone's hands are different, after all). If something feels wrong or is hurting, try using different fingers.


Yes. Always hit the modifiers with the opposite hand. This is taught in every keyboarding class, and applies to all modifiers, even Shift. This will make you a faster typist, and your hands will feel much better. Some newfangled keyboards don't include two sets of every modifier, so don't buy those. :)


I've been using vim for 3-4 years now. The plugin system is alright, but it's nothing to brag about. It's an amazing editor, but I think I'm going to try emacs + evil for a bit.

I almost added some other claims but I couldn't put them into words correctly, so I'll just leave it at this :D


Emacs is one of the most powerful and impressive programs I have ever seen. It just lacks a decent editor.


At least put the quotation marks around that. I'm pretty sure 95% of visitors to this comment page have seen that 100 times.


You know Emacs has faithfully implemented Vim right? Check out emacs evil-mode.


As a poke at Emacs' creeping featurism, vi advocates have been known to describe Emacs as "a great operating system, lacking only a decent editor".

From Editor War on Wikipedia


What an original and insightful comment. Thanks for sharing.


The best feature of emacs is running shells in buffers. For interactive work, this is supremely useful because you can easily search your history, grab previous lines/chunks of code, and edit them into future commands. I do this all the time for data exploration with python.


I like the M-x eshell function a lot, too. It supplies identical shell experience across every system which is capable to run emacs.


Have you ever tried Sublime Text ? I find it very powerful. But of course its GUI unlike emacs or vim.


I am not a developer but am learning programming. I picked up vim and have slowly build memory muscle for it for at least basic commands. I have never use Emacs. It seems to be quite popular. Is it worth learning? Is there a decisive answer to Emacs vs vim?


You should become intimately comfortable with a powerful text editor. Whether that is Emacs or Vim or Sublime Text does not matter too much.

I don't think there is any one axis that clearly marks Vim or Emacs superior. Both are awesome, geeky, sophisticated and powerful.


Is it worth learning this over Sublime Text? I love Sublime.


Certainly use whatever tools you like, however emacs and Sublime Text cannot be compared directly to one another.

Sublime Text and Vim or some other text editor can be, however text editing is a small component of emacs' utility to its users.

The reason is that emacs is an environment for running emacs lisp applications, and those target pretty much every imaginable niche.

There exists decades of development in that vein for emacs to the extent that for some domains it is an entirely self-contained ecosystem for that space.

The environment homogeneity is distinctly different from any other app which targets a subset of the tasks associated with an overall workflow; if we narrow the domain to just development a possibly valid comparison would be Visual Studio because of how the environment absorbs every interrelated aspect of development from communication to debugging etc. within one overall application.

Light Table may one day be similarly versatile though and a possible emacs alternative.


Sublime will do fine if you are't headed to Hogwarts. It's an awesome piece of software.


Learning is almost always worth it.


Kudo, But Time is of the essence


CTRL+F "vim"


/vim<CR>


Or C-h t


What benefits does Emacs have over something like Sublime? All I can see is you can customize a million key binds so you don't have to use the mouse. Sorry but I'm not racing type to as fast as possible when I write code, I don't mind spending an extra second and using a cursor.


If you're happy, keep on truckin'.

But to answer your question. This has been said a million times, but here's another angle. In a recent talk, Rich Hickey was talking about the design of electronic music modules:

> In other words, there's a human interface and a machine interface to the same > things. And the machine interfaces were there all the time — in fact, they were > first. And then the human interfaces come. We have to remember that as a > design thing. What's wrong with SQL? What's wrong with SQL is there's no > machine interface to SQL. They only designed a human interface to SQL, and > we've suffered ever since, cause we have to send these strings around. You can > always build a human interface on top of a machine interface, but the other is > often disgusting.

http://www.infoq.com/presentations/Design-Composition-Perfor... (at about 41:00)

Emacs is built on a machine interface first (elisp). Even the mouse actions in emacs are processed with elisp. So the human interface is not hard-wired. That's why hackers like it.


Emacs also binds almost any REPL (Python, Lisp dialects, Erlang...) There's also AucTeX if you need to write TeX (the best thing for LaTeX out there.) Emacs is also completely configurable with emacs lisp: you can write your own "things." For example, I have a mode I used to format posts for my blog: with just a few custom keybindings I had it formatted to my tastes and special CSS rules.

PS: Also, leaving the keyboard easily breaks the flow, specially when you are in the "damn, delete this whole line and start again" frenzy that is just milliseconds away from your neat idea. C-a C-k (this also works in most text boxes in Mac OS, though) is extra fast for this kind of things.

As for leaving the mouse, that's not the point. I'm a heavy emacs user, but my latest dwelling with Go have been using Acme (which is a mouse-heavy text editor) and it is very enjoyable, as a change of pace. But being in emacs is not "for the keyboard" as much as being in Acme is not "for the mouse."


I can't repeat myself enough.

TRAMP mode: http://www.emacswiki.org/emacs/TrampMode

I do plenty of work over ssh, and this saves me the headache of dealing with screens and multiple terminals.


Yup. I don't use tramp that much (well, in the last 4 months I used it daily, but...), but having it is great. Every time I have to edit more than 4 lines in a server I resort to it (if it's less I use nano or vim, because it usually means I'm in a ssh session editing some config file)


You can replicate a lot of that behavior in Sublime, plus you get a full GUI, file browser tree and it's easy to use and customize right away.

I'm not really convinced I should invest time in using emacs.


As a long time Emacs user a "Full GUI" or file browser tree are negatives. They just get in the way. There are alternative (and better) ways to navigate a file system that don't require pop-ups and other types of additional windows.

With Emacs directory navigation you can navigate into archive files such as .tar, .tgz and .zip without having to extract them.

Another Emacs benefit that Sublime may or may not support is that the editor's code can be customized simply by placing cursor at the function and typing a keystroke. Your code is then immediately active with no restarts or reloading.

Emacs works just as well in a OS window on my laptop and remotely running in a terminal. Being able to use the same editor locally and on a headless server is huge if you do server work at all.

You can run bash (or whatever) shells in emacs buffers. The full benefit of this is hard to describe, but once you try this you'll probably use it all the time.

In the end, you'll probably never be convinced by people advocating for Emacs, the best thing to do if you're really interested is to give it an honest try for a non-trivial period of time. Emacs can take time to learn but I think the payback is well worth it.


Completely agree with the payback. I'd never dream of going back to more IDE-like editors


I was not trying to convince you: if you are happy with Sublime, use it.


Personally, I use vim, but you can get a full gui using xemacs and it also is easy to customize with plugins. It also has the advantage that it can run in a terminal over ssh without X (server deployment).


No need to use xemacs, "standard" emacs has also a gui, file browser, etc etc. I use evil in emacs to have some of vims keybindings, btw


Long term Sublime user here. Recently dove deep into Emacs due to a need for Common Lisp arising.

Sublime is an excellent text editor. Emacs is an ancient book of magic spells, with a strange, hoary culture surrounding it. It is phenomenally powerful, and also very, very weird.

I still use Sublime for 'editing text', but for a mixed workflow with compilation, git commands, REPLs and shell scripts? Emacs. I suspect once I finish rolling Emacs into the precise form I want it, I will more or less stop using other tools.


You can also find me complaining about Emacs less than a month ago on this very site, and refusing to use it. It took a lot to push past the completely alien keystroke syntax, including a lot of installing re-binds that change it substantially.


I was an Emacs user back in the '90s. At some point I lost all my custom configuration and never had time to reconfigure.

A few weeks ago, I spent pretty much an entire day configuring Emacs, installing packages, themes, etc....In the end, things didn't really work awesomely. Key-binding issues on my OS X, certain short-cuts not working completely in org-mode, etc... (when not using an external keyboard, I absolutely abhor pressing the "option" key on my MBPro keyboard.)

Then I tweaked out Sublime Text. I appreciated how simple it was to change the themes, and install packages (though with emacs 24 m-x install-package was pretty simple, too), and it seems there's a package for anything (including a super-basic org-mode). And spending $70 on cross-platform closed source is probably worth my time that I save in configuration.

Though, who knows....I know enough VIM to edit server config files, maybe it's time I look into that for JavaScrip/Python development.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: