Hacker News new | ask | show | jobs
by maximilian 5318 days ago
In the article he links to "Emacs Prelude". From its README:

No arrow navigation in editor buffers

This is not a bug - it's a feature! I firmly believe that the one true way to use Emacs is by using it the way it was intended to be used (as far as navigation is concerned at least). That's why I've disabled all movement commands with arrows - to prevent you from being tempted to use them.

I don't use my arrow keys that much, but do any others see this as a useful feature? How do you typically navigate around code in Emacs?

3 comments

Mainly, I use my arrow keys for M-x tetris. ;)

To navigate, I typically use incremental search (C-s or C-r). Because moving up line-by-line is a slow linear process which gets annoying if you're not a couple lines away from the target.

You can also use the mouse, which is a very direct way of getting where you want to go.

There's also page up/down. (If you don't want to move your hands, that's C-v and M-v.) And for moving the screen (without moving the cursor), there's a quick C-l. If you want to go to the very ends of the buffer, there's M-< and M->.

Then there's linguistic motion, because you're often thinking in terms of moving in units of text. So, M-f if forward-word; M-} is forward-paragraph.

Then there's navigating units of code. Which is like moving in units of text, but you press control too. Like C-M-f is forward-sexp, which pushes you forward a code unit. (Like a string or variable name.) C-M-a is beginning-of-defun, which gets you to the start of the function/method/whatever you're in.

In my experience, nothing helps you change a muscle-memory habit as much as instant negative feedback. It doesn't help to remember 2 seconds after you did it, because then you've already told your brain "this works", and you can only go through so many "oh right, I wasn't supposed to do that" moments before you become demotivated.

When I first started using Emacs, I removed the arrow keys from my keyboard to force me to get used to C-(fbnp) and to this day, when I fiddle with my bindings, I still use that technique, though I'm slightly more sophisticated about it now:

  (global-set-key (kbd "C-+") (lambda () (interactive) (message "Use C-x C-+ instead.")))
I disabled them in my Emacs for the same reason - to force myself to use C-f, C-b, C-p, C-n and related keys instead. One problem with arrow keys is that they're far away from home row, so you need to move your hand quite much to the right to use them, and then back to the left to continue editing.