Live data from Hacker News

Keyboard shortcuts for GNU Readline

masteringemacs.org

71–80 of 174 posts

Re: Keyboard shortcuts for GNU Readline

#71
post #3

Just enable vim mode (`set -o vi`) and call it a day.

Yes! I never got the hang of the read line short cuts. Only one I remember and regularly use is reverse history search: ctrl-R. The downside is that while vim mode works nicely on bash, other commands like gdb etc that also use read line aren’t as easy to get into vim mode, if they support it at all…

ime, most programs using readline parse ~/.inputrc.

  set editing-mode vi
  set keymap vi-command
That does the trick for me in python shell, psql, etc.

First thing I do on any fresh unix box is setting above, and echo "set -o vi" >> ~/.bash_profile.

Re: Keyboard shortcuts for GNU Readline

#73
post #71

Earlier quoted context omitted.

Yes! I never got the hang of the read line short cuts. Only one I remember and regularly use is reverse history search: ctrl-R. The downside is that while vim mode works nicely on bash, other commands like gdb etc that also use read line aren’t as easy to get into vim mode, if they support it at all…

ime, most programs using readline parse ~/.inputrc. set editing-mode vi set keymap vi-command That does the trick for me in python shell, psql, etc. First thing I do on any fresh unix box is setting above, and echo "set -o vi" >> ~/.bash_profile.

For programs which use libedit, you can also setup vi mode.

    bind -v

Re: Keyboard shortcuts for GNU Readline

#74
post #6

I'm using bash (and thus GNU readline) all day every day at work, and by far the most useful shortcut for me is Ctrl-r (reverse history search). I also sometimes use Ctrl-a (start of line, if the keyboard doesn't have a convenient Home key) and Ctrl-e (end of line, in lieu of End key). Btw the post disses Ctrl-s / Ctrl-q for pausing/resuming terminal output, but it can be useful when you're outputting a lot of text (…

I agree with you. What I have also done is increase the history size:

https://eshlox.net/2017/08/01/bash-increase-command-history-...

Re: Keyboard shortcuts for GNU Readline

#75

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 switched to Mac full time when I got frustrated with my Linux desktop having (far) worse support for Emacs keybindings than my work Mac. There was a certain amount of irony in it.

Re: Keyboard shortcuts for GNU Readline

#76
post #4

Earlier quoted context omitted.

Can I still use macros with 'q '?

You can edit the current prompt in a full vim by pressing ‘v’. On :wq the content of the file will be run as the command. In that case you can use the macros with q (and any fancy vim plugin you might like)

Best of Both worlds: Normal readline shortcuts, and hold control whilst pressing x and e (C-x,C-e) to open that line in $EDITOR (i.e. vim).

Re: Keyboard shortcuts for GNU Readline

#77
post #61

Earlier quoted context omitted.

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

It's Emacs not eMacs! ;) https://irreal.org/blog/?p=10973 )

TIL people write eMacs on purpose. Mine was just iPhone's autocorrector as someone mentioned in the comments.

Re: Keyboard shortcuts for GNU Readline

#78

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…

If we are doing a survey.

Firefox on openbsd uses the emacs keybindings.

And just checked, it looks like chrome on openbsd uses the emacs keybindings as well. it just reinforces my feeling that openbsd makes the best desktop system.

Re: Keyboard shortcuts for GNU Readline

#79
post #3

Just enable vim mode (`set -o vi`) and call it a day.

vi bindings aren't worth running into weird problems imo. it took me less than a minute to hit an incompatibility with fzf. https://github.com/junegunn/fzf/issues/1238

This is it for me. I'd use vi bindings everywhere if I could and it didn't end up breaking other things.

Re: Keyboard shortcuts for GNU Readline

#80

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…

You can enable "Emacs bindings" in a bunch of applications. Enabling that in GTK would let you use the cursor movement keys in Chrome and Firefox. https://askubuntu.com/a/1280532

You are a hero and have just cured me of a hundred daily paper cuts. My employer should give you a bonus.

It works in Chrome, but unfortunately not in the standalone Slack client. (Maybe an argument for switching to the web version?)

(Uh, does anyone know how I select all (previously C-a) or search (previously C-f) in Chrome now??)

EDIT: Looks like C-/ functions as select all, still looking for a find replacement.

EDIT #2: Oh, silly me, as long as I'm not focused on an input, C-f still works.

Post reply on HN