Live data from Hacker News

Keyboard shortcuts for GNU Readline

masteringemacs.org

81–90 of 174 posts

Re: Keyboard shortcuts for GNU Readline

#81

Earlier quoted context omitted.

Who has time to move all of the way over to the arrow keys, tap a few times and then find the little tab on the J again? I have arrows behind a second layer on my keyboard with vim mapping, and I don't think I could give that up. If you spend all day in front of a keyboard you might as well learn to be efficient with it.

> I have arrows behind a second layer on my keyboard with vim mapping Same here: second layer reachable from the hands' home position on the keyboard. Left thumb for the modifier + ijkl in my case (I like ijkl for it mimics an actual arrows key cluster). It works everywhere: xterm / command line, Emacs, any editor / IDE really, any dropdown menu... It's the way.

jkl of course works on youtube, I find it really annoying when viewing other video sites which don't support these basic keybindings

Re: Keyboard shortcuts for GNU Readline

#82
post #71

Earlier quoted context omitted.

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

Good one! That covers sqlite3, it was my last straggler. :)

Re: Keyboard shortcuts for GNU Readline

#83
TIL

Although GNU readline maintains a kill ring (clipboard), which works much like Emacs’s kill ring, it’s not shared with your system’s clipboard, nor any other instances of GNU readline. It is, in effect, local to the process you’re running.

so it's not just that I didn't copy something...

Re: Keyboard shortcuts for GNU Readline

#85
post #68

Ctrl-R! Ctrl-R! Ctrl-R! How many people have been on a screen sharing call and watched the other person tediously up-arrow through 5-10 commands to try to rerun what they just did? The single greatest productivity boost you can gift a CLI newbie is searching their command history. Everyone jumps on the Emacs nav keys (C-f, C-b, etc) or other editing trivia. No one has trouble editing a command in place but it certain…

For extra boost, add fzf and its shell integration. https://github.com/junegunn/fzf

I missed the shell integration when switching to Fish a couple of years ago. fzf.fish saved the day, I wouldn't be without the keybindings now (Ctrl+Alt+F is roughly the equivalent of **Tab)

https://github.com/PatrickF1/fzf.fish

Re: Keyboard shortcuts for GNU Readline

#87

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…

C-a, C-k are probably my most used shortcuts on the mac

My favorite is that those can combined with the shift key, to get native highlighting. So Ctrl-Shift-a works like Shift-Home on windows (and Ctrl-Shift-e for Shift-End).

So you can do C-s-a and C-s-e, followed by cmd-C, to copy stuff to the native clipboard.

(Kill and yank (C-k and C-y) work too, but not across applications.)

Re: Keyboard shortcuts for GNU Readline

#88

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 try to move my cursor up to edit a previous line using C-p and end up brining up a print dialogue.

I used to be a big enthusiast of keyboard shortcuts, now I’m getting fed up of how many there are, every program has a zillion shortcuts all stacked on top of each other. Someone needs to come up with a better way (cough Jeff Raskin THE?).

This one is notably egregious, hands up anyone who prints often enough to need a keyboard shortcut; someone who prints as often as they new-tab, as often as they Ctrl-s a text file, as often as they copy/paste? Anyone? If only there was a universal way to unbind them.

Re: Keyboard shortcuts for GNU Readline

#89

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…

Ugh this destroyed my productivity too for a while. I even wrote an entire blog post about my woes and different experiments to get back to getting consistent shortcuts across terminal and GUI apps here: https://alexdav.id/2020/07/12/text-manipulation-and-modifier.... GTK key themes didn't end up working out for me, and I ended up with a custom QMK solution, but it's not great.

Note for people still using macos, you can enable many more readline shortcuts by creating a special file at ~/Library/KeyBindings/DefaultKeyBinding.dict. I made a repo that simplifies the process to just a single git clone when setting up a new machine: https://github.com/alexdavid/keybindings

Re: Keyboard shortcuts for GNU Readline

#90
post #23

Earlier quoted context omitted.

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

Oh my gosh thank you. I once went back by a word and swore I hallucinated, then realized the shortcut probably exists but never bothered to look into it.

The emacs shortcut works here too: Alt-b for back a word and Alt-f for forward a word (at least if your terminal maps alt correctly)
Post reply on HN