Live data from Hacker News

Keyboard shortcuts for GNU Readline

masteringemacs.org

31–40 of 174 posts

Re: Keyboard shortcuts for GNU Readline

#31

For anyone using a Mac, the basic cursor movement commands available in readline and emacs—C-f, C-b, C-a, C-e, C-n, C-p—are also available in virtually any text input in any program, namely web browser inputs, url bars, and textareas, as well as all system UIs. Once you get used to using these shortcuts that means you can compose and edit text anywhere without ever moving your hands. I recently switched to using Linu…

I’m not sure about other OSs, but having cmd for standard mac shortcuts and ctrl for all things Linuxy is really useful in general. As you point out, loads of apps support the standard readline controls. I additionally wire ctrl-p / ctrl-n to be more generally useful in Linux and vim, but I find that they just work all over the place in Mac apps too (up / down in Alfred search results for example).

Re: Keyboard shortcuts for GNU Readline

#32
post #27

> C-e, C-f, M-b, M-f Why these strange shortcuts when any keyboard has arrow keys and they can be used with a control modifier to move by words? I can understand why to use C-a, C-e, because laptop keyboards tend to have "Home" and "End" keys in strange places, but those... And Emacs documentation for some reason insists on using C-e, C-f instead of arrow keys.

Not a eMacs person, but as a vim user arrow keys are annoying to reach. Using control or vim bindings it is far easier for me

Re: Keyboard shortcuts for GNU Readline

#33
post #23
post #11

Knowledge like this used to spread naturally—physically sitting with a junior engineer, muscle memory would make any shortcut-fu gaps painfully clear. That’s not as visceral in remote pairing, and doesn’t show up at all in async processes like CR. Still, I try to at least share the “greatest hits”: ctrl-r: search backwards through command history ctrl-a: go to beginning of line ctrl-e: go to end of line If nothing el…

In ~20 years of professional programming, I have never explored much beyond these shortcuts, except for also using: * ctrl-left/ctrl-right to go back/forward word by word instead of char by char * ^C to cancel the current line

If we're counting ^C, then I'd also add:

  * ^D - Send EOF, which exits most shell-like programs (if you're on an empty line, so try ^C^D)
And the job control bindings:

  * ^Z - Suspend current foreground process and return to shell, use `fg` to resume it in foreground and `bg` to resume it in background (see also `disown`)
  * ^S - "Stop" current process, useful if it's printing a lot of stuff and you want to pause it for a bit, otherwise useless and usually done by mistake
  * ^Q - resume a stopped process, probably after you ^S'ed by mistake

Re: Keyboard shortcuts for GNU Readline

#34
post #27

> C-e, C-f, M-b, M-f Why these strange shortcuts when any keyboard has arrow keys and they can be used with a control modifier to move by words? I can understand why to use C-a, C-e, because laptop keyboards tend to have "Home" and "End" keys in strange places, but those... And Emacs documentation for some reason insists on using C-e, C-f instead of arrow keys.

Ctrl used to be where Caps Lock is on some keyboards and today, you can map Caps Lock to Ctrl in Mac OS snd Linux. It will make more sense when you do that as pressing the shortcut will be much easier (home row).

Re: Keyboard shortcuts for GNU Readline

#35

For anyone using a Mac, the basic cursor movement commands available in readline and emacs—C-f, C-b, C-a, C-e, C-n, C-p—are also available in virtually any text input in any program, namely web browser inputs, url bars, and textareas, as well as all system UIs. Once you get used to using these shortcuts that means you can compose and edit text anywhere without ever moving your hands. I recently switched to using Linu…

Command-A isn’t available on Linux in slack? How do people even function without basic function keys?

Let me introduce you to the Home key: https://en.wikipedia.org/wiki/Home_key

Re: Keyboard shortcuts for GNU Readline

#36
post #27

> C-e, C-f, M-b, M-f Why these strange shortcuts when any keyboard has arrow keys and they can be used with a control modifier to move by words? I can understand why to use C-a, C-e, because laptop keyboards tend to have "Home" and "End" keys in strange places, but those... And Emacs documentation for some reason insists on using C-e, C-f instead of arrow keys.

On laptop one requirement I have is having these:

fn+left/right -> home/end

fn+up/down -> page up/down

It's probably been 20 years I have laptops that support it and I'm perfectly fine/fast to manipulate text with the keyboard.

Re: Keyboard shortcuts for GNU Readline

#38
post #27

> C-e, C-f, M-b, M-f Why these strange shortcuts when any keyboard has arrow keys and they can be used with a control modifier to move by words? I can understand why to use C-a, C-e, because laptop keyboards tend to have "Home" and "End" keys in strange places, but those... And Emacs documentation for some reason insists on using C-e, C-f instead of arrow keys.

> Why these strange shortcuts when any keyboard has arrow keys and they can be used with a control modifier to move by words?

There was a time before PC's when keyboards didn't necessarily have Arrow keys

Re: Keyboard shortcuts for GNU Readline

#39

For anyone using a Mac, the basic cursor movement commands available in readline and emacs—C-f, C-b, C-a, C-e, C-n, C-p—are also available in virtually any text input in any program, namely web browser inputs, url bars, and textareas, as well as all system UIs. Once you get used to using these shortcuts that means you can compose and edit text anywhere without ever moving your hands. I recently switched to using Linu…

Command-A isn’t available on Linux in slack? How do people even function without basic function keys?

Command-A does select all. On Linux if you use defaults, ctrl+A will do that. If you change your gtk keyboard shortcut theme to ‘emacs’ it will do the equivalent of ‘home’ instead (which is what ctrl-A does on a Mac). To delete a message under these conditions, you can usually do e.g. C-A C-K. But that’s not so suitable for eg a high-risk text box on a buggy site where you want to regularly select all then copy in case the site crashes or loses your data.

Re: Keyboard shortcuts for GNU Readline

#40
post #27

> C-e, C-f, M-b, M-f Why these strange shortcuts when any keyboard has arrow keys and they can be used with a control modifier to move by words? I can understand why to use C-a, C-e, because laptop keyboards tend to have "Home" and "End" keys in strange places, but those... And Emacs documentation for some reason insists on using C-e, C-f instead of arrow keys.

They work everywhere. Decades ago, the Home/End/PgUp etc keys might not work on all terminals.

You can use the standard keyboard movement keys if you prefer.

(The letters are mnemonics, Back, Forward, Next line, Previous line, End of line, start of line uses A as the first letter. The control key tends to do smaller things (like move one letter or line) while the alt/meta key does bigger or less-common things, like move whole words, sentences or paragraphs. See https://www.gnu.org/software/emacs/manual/html_node/emacs/Mo...)

Post reply on HN