Emacs, keypresses, and why keyboard combinations aren't that scary
Posted: - Modified: | emacsI came across this comment on Chris Lowis' blog post about small-screen development in Emacs:
Alex: I can't be geek enough to use Emacs… it's not that I think the
editor is bad: it's the excessive number of keys to press to
accomplish anything.
It made me stop and think, because one of the things I love about Emacs is that I can press lots of keys to accomplish anything.
What's the alternative? Mouse clicks? Eeew.
My most-common keyboard shortcuts are one or two keys long. Yes, there are many of them, and I use a small subset depending on what I'm working on. If I forget the keyboard shortcut for something, or I want to run a command that doesn't have a keyboard shortcut, I use M-x (which is really Alt-x on my keyboard) to call the function by name (ex: M-x shell-command-on-region, which turns out to have M-| as a shortcut).
I hardly ever type entire function names. icomplete-mode
offers autocompletion for M-x. I also shows me the keyboard shortcuts for a command in order to help me work more efficiently.
If I like something a lot, I can easily define a keyboard shortcut for it using global-set-key. I can set mode-specific keyboard shortcuts so that some shortcuts are active when I'm programming and inactive when I'm not. I can load sets of shortcuts depending on what I want to do. It's incredibly flexible. Yes, it requires some learning, but it's been well worth the investment for me.
Because you only have so many keys on a keyboard, it's useful to be able to define multiple-key shortcuts. I'd rather type Ctrl-c r t than Ctrl-Alt-Shift-R or something like that. (Or worse: spend time looking for just the right toolbar button, and try to click on it with the mouse.) I think of it like super-fast selection through a menu that makes sense to me. In my case, Ctrl-c turned out to be easier to get to than F9 (which I'd previously been using for personal shortcuts), r means remember, and t means task.
You might think that a keyboard-driven editor is slow, but it's fast enough to keep up with me, and I can probably code circles around you. ;)
17 comments
Chris Thompson
2010-10-31T07:41:40ZI think the complaint that people have about sequences of keystrokes isn't necessarily about the keystrokes themselves... it's about the memorization required as a prerequisite to using those keystrokes. In a lot of cases, there aren't menu or graphical alternatives to a given set of keystrokes, so one does kind of have to memorize them, or write them down.
Some modes are better than others in this respect. Org-mode has a really well thought out set of menus. I must use the clock-in and clock out commands at least 40 times a day, and I still use the menu items with the mouse because I find it hard to remember the triple key combinations for these commands. It's okay though, because the menus exist! Eventually I'll learn the keystrokes. Org-mode is worth the learning curve.
Sacha Chua
2010-10-31T21:26:17ZI don't generally enjoy memorizing things, which made calculus quite a struggle for me. <laugh> For Emacs, I haven't memorized a lot of keystrokes, and I occasionally turn to M-x where-is, icomplete-mode, or the C-h keybinding (tack it onto the end of any keyboard shortcut prefix) to learn more. When I find myself getting annoyed by a shortcut I can't remember, I create a new shortcut that makes more sense for me. I never use the menus these days, because I hate using the mouse. <laugh> But yes, Org-mode is definitely worth the learning curve!
As for clock-in and clock-out - if you're doing this based on tasks, you might want to set things up to automatically clock you in when you mark a task as STARTED and clock you out when you're done. This might help: http://sachachua.com/blog/2...
Chris
2010-11-04T16:52:41ZI too vastly prefer keys over the mouse or menus, and I've found it possible to arrange my Emacs keybindings so that almost all have some mnemonic meaning. Setting up prefix maps is key (ha ha) to this. For example, I've used the rectangle commands almost every day for years, and what made that easy was putting them in the C-x r prefix in my own way. This often involved remapping the defaults, and it did take a little thought and practice initially. But the many sequences I use often have become second nature.
Also have you tried out icicles or anything yet? I started using them recently and am very pleased. Icicles took me a while to get used to, and I haven't finished configuring it yet, but it is very powerful. It gives immediate command *and* keystroke completion among many other things. I also started with YASnippets recently as well, and it's terrific.
Sacha Chua
2010-11-04T17:01:49ZI should give Icicles another try. =) I checked it out when I saw so much activity around it on EmacsWiki, but I felt overwhelmed by all the things it was doing, so I went back to ido+icomplete. It looks very useful, though.
YASnippets totally rocks. =) What are you doing with it?
Ciaran Mulloy
2010-11-15T18:28:36ZI think the biggest issue for me is finding out all the functionality that available and how it works. I've come to emacs later in life and was attracted initially to the capability of Org-mode but began to see the logic of reducing many things to text files as it goes a long way to simplfying my life and getting things done. For me the problem is not so much remebering the key-stroke, although I believe that that will be a problem too, it's more about understanding how I go about doing something in emacs that I did on MS Word or Openoffice.org and what the equivalent function name would be in emacs. Often times there's a totally different way of dealing with a particar issue in emacs.
Sacha Chua
2010-11-15T19:10:01ZEmacsWiki is a great resource for that. It's often like virtually watching over the shoulders of other Emacs users. Feel free to ask me questions or post on the Emacs mailing lists or newsgroups, too. Plenty of people remember what it was like to be learning about all sorts of stuff, and can help you find what you need.
David Dyer-Bennet
2010-11-17T20:46:13Z"Excessive number of keys to press"? I guess it depends where your hands start out. When I'm working with text, my hands start out on the keyboard, and having to move to the mouse takes more time than a LOT of keystrokes.
It's true there's a learning curve. Emacs is friendlier to beginners than most programs, but at bottom it's an "expert" user interface, designed for efficient work by people familiar with it.
Anybody know if XKeymacs is going to be updated to work with Windows 7? I keep finding myself half a dozen keystrokes down some editing path before my brain notices that the computer isn't doing what I want. I started using Emacs in 1981 (ITS emacs, yes, written in TECO, under the incompatibility package on TOPS-20), and my finger don't really know how to do anything else at this point.
Sacha Chua
2010-11-17T23:43:21ZI had no idea XKeymacs existed. Pretty cool! =) Thanks for sharing. My approach is to do as much as I can within Emacs, which gets around the non-Emacsiness of other programs... ;)
David Dyer-Bennet
2010-11-18T01:29:19ZI've never really gotten into using Emacs as a web browser; and I write a lot of comments on LiveJournal and Making Light and various blogs, so being able to do that editing with emacs keystrokes for the things I do without thinking makes my life a lot easier. But yea, browsing those sites directly in Emacs is a more direct solution, if it works.
Borbus
2010-11-18T06:58:47ZI really don't remember ever making an effort to memorise key combos. When I first started using emacs I actually went through the tutorial (C-h t) and by the end of it the navigation keys (C-f C-b etc.), search, save, open, switch buffers etc. keys were firmly engrained in my muscle memory. I actually had to think about the C-f and C-b keys because I don't ever actually think about pressing them, I just think about navigating one letter forward or backwards.
Some key combos that can't be global (such as language specific compile commands etc.) I have made consistent across all of the modes that I use. For example, C-c C-c means "build" or "make" or the closest analogous command in all major modes that I use (if applicable). This sort of thing makes "remembering" the keys a lot easier.
But really I couldn't tell you how many key combos I actually know. I just don't consciously think about it. Just like you don't consciously think where each letter is on the keyboard every time and you don't think about which English word to select each time when you speak.
And I easily run circles around mouse users! If a mouse user happens to see me using emacs it's not unusual for them to be left half in awe and half in confusion at what just happened during the couple second fury of keyboard bashing that just happened. (I disable *all* graphical stuff in my emacs, my frames are 100% text).
Sacha Chua
2010-11-18T16:08:27ZDavid: There are browser plugins that let you invoke an external editor on text areas. Firefox: It's All Text . Might help! =)
Borbus: Yes, absolutely! =) Rock on.
David Dyer-Bennet
2010-11-18T21:06:58ZIt's All Text! seems to represent an advance over the state of the art last time I looked at that sort of thing. I'll give that a try on my W7 box, thanks!
Victor Calvert
2010-11-25T03:21:59ZOne of the features I'm interested in which would help the keyboard issue is something like what TSE Pro has (from SemWare). It's a popup that you see once you use a prefix key with the available additional keys and a one-line (usually ~5 word) description of what it does. The only real downside to that editor (aside from costing ~$100 and not being available on Linux) is that you only have two levels of keys. Does anyone know of something like that for Emacs?
Also, regarding things like It's All Text, there is an Edit With Emacs extension for Chrome/Chromium; it has a keyboard shortcut but that's not working properly on my machine at the moment.
Sacha Chua
2010-11-25T06:35:49ZI usually hit C-h after a prefix if I've forgotten or I'm curious about what the options are. =) Works for me because I usually speed through the shortcut anyway, and I don't like having too many distracting things going on. <grin>
Victor Calvert
2010-11-28T22:58:43ZTrue enough; it's a delay-based menu so if you speed through you don't see anything but the status line. From what I remember, it takes about half a second to a second to pop up, so if you're fast it doesn't impact anything, but it effectively automates the process of getting help in certain circumstances where help would be helpful (heh), without being as annoying as some of the things I've seen elsewhere (Microsoft being one of the culprits).
All I'm really interested in is if someone has already written the code to have Emacs act as if I've hit C-h if I pause during a key combination for a second or two. I'm sure it's possible, through a custom hook if nothing else, but wasn't sure if someone had already done it.
datnt
2011-01-28T12:23:37ZHi Sacha,
Do you have any plugin for emacs that support drawing just like Windows XP's paint?
Thank you,
Dat
Joe Bloggs
2011-02-02T07:54:40ZVictor Calvert: here is the answer to your question: http://www.emacswiki.org/em...