13 ms·
Start Using Emacs – A Thorough Guide for Beginners
- michaelsbradley 13y agoAs an Emacs beginner and budding Clojure programmer in early 2012, I benefited greatly from Bozhidar Batsov's Emacs Prelude: https://github.com/bbatsov/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+.
- babarock 13y agoAnd you shouldn't miss Bozhidar's blog on Emacs (http://emacsredux.com/ http://emacsredux.com/) where he explains a lot of the very cool techniques he included in Prelude.
- singular 13y ago> 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.
- tazjin 13y agoWhen you say vanilla emacs, do you include the Cocoa version? (http://emacsformacosx.com/ 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.
- blueblob 13y ago+1 so funny, vanilla=cocoa...
- tazjin 13y agoI 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.
- blueblob 13y agoI 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.
- singular 13y agoYes, 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.
- intranation 13y agoPATH, 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 https://github.com/purcell/exec-path-from-shell
- mmariani 13y agoAfter 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.
- AndreasFrom 13y agoI tend to switch back and forth between Vim and Emacs and am curious. What causes the hate in your relationship with Vim?
- cgag 13y agoI'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.
- mmariani 13y agoVim 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.
- tiziano88 13y agoCan Emacs replace eclim (eclipse + vim) as a Java IDE? Are there plugins that can make editing Java in Emacs nicer and more productive?
- ulisesrmzroche 13y agoLots 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.
- tiatia 13y agoEmacs is one of the most powerful and impressive programs I have ever seen. It just lacks a decent editor.
- dasil003 13y agoAt least put the quotation marks around that. I'm pretty sure 95% of visitors to this comment page have seen that 100 times.
- davexunit 13y agoWhat an original and insightful comment. Thanks for sharing.
- lord_quas 13y agoYou know Emacs has faithfully implemented Vim right? Check out emacs evil-mode.
- justinhj 13y agoAs 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
- kenrose 13y agoGreat 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".
- nonrecursive 13y agoGreat feedback, thanks! I'll work it in.
- burgerz 13y agoWhat 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.
- RBerenguel 13y agoEmacs 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."
- burgerz 13y agoYou 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.
- blueblob 13y agoPersonally, 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).
- RBerenguel 13y ago
- rickdale 13y agoWhen 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.
- abrichr 13y ago> ... 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... ;)
- philangist 13y agoWas his name Mr. Miyagi?
- harshreality 13y agoFinally 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 http://www.youtube.com/watch?v=fCbf4DjlHuM#t=0m31s
- rrmm 13y agohah! I did this to people too. I ended up popping the keycaps of the arrows off the keyboard and taping over the hole.
- liyanage 13y agoI 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?
- roryokane 13y agoOne 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.
- ultimoo 13y agoI 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.
- liyanage 13y agoUnfortunately the option-as-meta setting applies to both left and right option keys.
- tazjin 13y agoiTerm 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/ 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.
- cpr 13y agohttp://lmgtfy.com/?q=typing+special+characters+into+emacs 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.
- outworlder 13y agoFinally 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.
- lord_quas 13y agoThis 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 https://github.com/jasonm23/emacs-purple-haze-theme
- terhechte 13y agoInterestingly, I use Soothe (https://github.com/jasonm23/emacs-soothe-theme 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.
- lord_quas 13y agoIndeed, I used Soothe for a while too. Loved that as well.
- laichzeit0 13y agoAny 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.
- lokedhs 13y agoIf you want to preserve your vision, you probably want to change those colours. You need dark text on light background.
- Matti 13y agoEmacs-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 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 https://github.com/emacs-helm/helm * Sunrise Commander: MC-ish file explorer, based on Emacs's Dired: http://www.emacswiki.org/emacs/Sunrise_Commander http://www.emacswiki.org/emacs/Sunrise_Commander
- RBerenguel 13y agoI think you may also like key chord-mode: http://www.emacswiki.org/emacs/KeyChord http://www.emacswiki.org/emacs/KeyChord
- sb 13y agoSeconded! Especially with magit (and I suppose with vc in general) key chords are really nice.
- agumonkey 13y agorecent alternative https://github.com/chrisdone/god-mode https://github.com/chrisdone/god-mode
- RBerenguel 13y agoI 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
- mrdraper 13y agoCTRL+F "vim"
- maxk42 13y ago/vim<CR>
- asgard1024 13y agoI 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.
- lord_quas 13y agoIDE'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.
- goblinfoblin 13y agoThe 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.
- asgard1024 13y agoI 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?
- swah 13y agoEmacs makes Windows more bearable - thats why I'm thinking of returning.
- computer 13y agoQuestion 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?
- jzawodn 13y agoI just realized that I use my thumb for that.
- jcurbo 13y agoI tend to use my left thumb. Seems to be close enough on PC and Mac keyboards that muscle memory works fine.
- spudlyo 13y agoThe 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.
- alokv28 13y agoOn 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 https://sites.google.com/site/steveyegge2/effective-emacs
- beffbernard 13y agoI 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.
- jcurbo 13y agoI 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.
- cgag 13y agoInteresting, I honestly was pretty confident no one who got used to modal editing ever wanted to go back to crazy key chording.
- Baalbetherim 13y agoI 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.
- jcurbo 13y ago
- runeks 13y ago> Go ahead and undo that change. How do I do that? Thanks for the guide by the way!
- spacemanaki 13y agoC-_ 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.
- shire 13y agoIs it worth learning this over Sublime Text? I love Sublime.
- Derbasti 13y agoLearning is almost always worth it.
- shire 13y agoKudo, But Time is of the essence
- enscr 13y agoSublime will do fine if you are't headed to Hogwarts. It's an awesome piece of software.
- mheathr 13y agoCertainly 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.
- sb 13y agoI 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 http://m00natic.github.io/emacs/emacs-wiki.html Additional resources I found helpful: http://www.emacswiki.org/emacs/EmacsNiftyTricks http://www.emacswiki.org/emacs/EmacsNiftyTricks http://web.psung.name/emacstips/essential.html http://web.psung.name/emacstips/essential.html Plus, check out the videos from Magnar Sveen's emacs rocks: http://emacsrocks.com http://emacsrocks.com
- andrewflnr 13y agoIrrespective 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.
- nonrecursive 13y agoThank you!
- sbuccini 13y agoI'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?
- Fishkins 13y agoI 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.
- sbuccini 13y agoSo for C-x, I should hit the command key with my right hand?
- __david__ 13y agoFirst 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.
- dima55 13y agoYes. 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. :)
- __david__ 13y agoThis 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.
- tux 13y agoHave you ever tried Sublime Text ? I find it very powerful. But of course its GUI unlike emacs or vim.
- minor_nitwit 13y agoOr C-h t
- hogu 13y agoThe 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.
- Tezro 13y agoI like the M-x eshell function a lot, too. It supplies identical shell experience across every system which is capable to run emacs.
- donniezazen 13y agoI 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?
- Derbasti 13y agoYou 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.
- codygman 13y agoI'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