Lurker News
What things (books, activities, courses - anything really) have richly rewarded the time you invested in mastering them?

Comments (563) 147 threads

Show all comments

Showing thread 5 of 147

msluyter4 replies#
Readline —- I’m sometimes amazed at the number of relatively seasoned developers who don’t know simple commands like ctrl-r. This one really pays off because almost all shells and repls like ipython or the mysql client implement it.

Sample cheat sheet:
https://readline.kablamo.org/emacs.html
You don’t have to learn it all, but mastering the basics like moving to the end/beginning on the line, moving/deleting by word, yank, history search and the like will pay off handsomely.

hoosieree1 reply#
Huge fan as well. What I really want is a terminal which has Vim's "normal mode" keybindings for scrolling back the buffer, selecting, find/replace... but then anytime you go to "insert mode", you get Readline. Best of both worlds.
paulriddle1 reply#
I think that's Neovim's terminal mode. I personally don't use it because I use a tiling window manager, so it's easy to launch another terminal wherever I want and I'm happy with the key bindings. But some people swear by terminal mode.
hoosieree#
Thanks for the pointer, I'll check it out.
todd38341 reply#
Nice! I’ve been at this game for a while and ctrl-r must have slipped right past me till now. I’ve regularly do ‘history | grep ___’ but ctrl-r looks like a far better solution.
twinge1 reply#
If you're a vi user, edit ~/.inputrc and add:

   set editing-mode vi
   set keymap vi-command
This changes readline behavior from emacs to vi. This, along with "set -o vi" in bash, are really handy (though can be frustrating for others if you ever share a keyboard pair programming).
Cyph0n#
In Zsh, it will set the editing mode to whatever your $EDITOR is set to. So if $EDITOR == vim, readline will be set to vim mode.

I’m a vim person, but I feel like the modal workflow does not work well at all in a shell.

ajmurmann1 reply#
Lots of the commands work in many macOS GUI apps as well.
mycelium#
The origin of those shared commands isn't from readline, but rather from emacs key bindings that made it into both readline and MacOS: https://jblevins.org/log/kbd