by CodeIsTheEnd · 4y ago · 0 comments
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 Linux full time for my job and it KILLS me that these shortcuts aren’t available outside of the terminal. I try to navigate to a search suggestion in Chrome using C-n and accidentally open three new windows. I try to add a sentence at the start of Slack message using C-a and accidentally highlight everything and delete it. I try to move my cursor up to edit a previous line using C-p and end up brining up a print dialogue. It’s breaking the muscle memory of my most basic interactions with the computer, and it sucks.
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
What keys do ~ and ^ represent?
{
"^w" = "deleteWordBackward:";
"~f" = "moveWordForward:";
"~b" = "moveWordBackward:";
"~d" = "deleteWordForward:";
"~<" = "moveToBeginningOfDocument:";
"~>" = "moveToEndOfDocument:";
"~w" = "copy:";
"^y" = "yank:";
"^t" = "transpose:";
"^p" = "moveUp:";
"^n" = "moveDown:";
"^u" = "deleteToBeginningOfLine:";
}^ = Control
~ = Escape
0: I think VT100, but don't quote me on that
1: or possibly "1B 78", depending on how it handled shift; I don't remember exactly.
I use a variant of the emacs key theme, so I'd be happy if there were a workaround...
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.
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.
https://irreal.org/blog/?p=259
I really missed C-w for delete word personally.
There's also a vim plugin by tim pope that adds a few readline keys that don't clash.
https://github.com/tpope/vim-rsi
And if you use the fish shell you can have both vi and Emacs shortcuts activated at the same time for the best of both worlds.
https://github.com/jrus/cocoa-text-system/blob/master/KeyBin...
Though I just have:
"^w" = "deleteWordBackward:"; /* C-W Delete word backward */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.
So the configuration file is ~/.editrc.
man editrc
Note also that to have a full mapping of keys available to you, you have to be aware of the tty settings (see stty), the terminal emulator and the GUI environment in which it is running. I would appreciate a tool that would dump all this in a comprehensive list.
[0] for example in the quakelive console
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.)
How do people even function without basic function keys?