10 ms·
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
by CodeIsTheEnd 4y ago
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 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.
- sillysaurusx 4y agoCommand-A isn’t available on Linux in slack? How do people even function without basic function keys?
- noisem4ker 4y agoLet me introduce you to the Home key: https://en.wikipedia.org/wiki/Home_key https://en.wikipedia.org/wiki/Home_key
- aliqot 4y agoI've always pried this key and other useless keys off my keyboards. TIL.
- dan-robertson 4y agoCommand-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.
- aplaice 4y agoDoesn't ctrl+/ select all in either GTK key theme?
- chaosite 4y agoYou 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 https://askubuntu.com/a/1280532
- aplaice 4y agoUnfortunately, GTK 4 has removed key themes. Eventually, Firefox, Chrom(e|ium) and all actual GTK applications will migrate to GTK 4, so this is not very future-proof. I use a variant of the emacs key theme, so I'd be happy if there were a workaround...
- tmtvl 4y agoIt's unfortunate that the GTK devs feel they have to remove features which their users find useful to keep GTK maintainable. Keeping software complexity under control is a difficult task, and I can't begrudge them their choice.
- CodeIsTheEnd 4y agoYou 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.
- aidos 4y agoI’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).
- ZeroGravitas 4y agoOn Mac Os you can also add some other ones that are not enabled by default, there's various write ups on how to do this. https://irreal.org/blog/?p=259 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 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.
- ckolkey 4y agoSeems quite cool - I don't suppose you have a copy of the .dict file linked in that blog post? the link is 503 :\
- ZeroGravitas 4y agoThere's a link in the comments to it. https://github.com/jrus/cocoa-text-system/blob/master/KeyBindings/Emacs%20Esc%20Bindings.dict https://github.com/jrus/cocoa-text-system/blob/master/KeyBin... Though I just have: "^w" = "deleteWordBackward:"; /* C-W Delete word backward */
- ckolkey 4y agoMissed that - thanks :)
- ornornor 4y agoUntil you get used to C-w in any text box, and then randomly close browser tabs (ff on Linux) because muscle memory.
- Oxidation 4y agoOpening the Firefox console with Shift+Ctrl+C is my particular habit. Of course the shortcuts aren't configurable, it's 2022.
- ris58h 4y agoDon't confuse Mac's Ctrl with Ctrl on Win/Linux. Mac's equivalent to non-Mac's Ctrl is Cmd.
- chrisBob 4y agoC-a, C-k are probably my most used shortcuts on the mac
- mh- 4y agoMy 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.)
- jurip 4y agoI 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.
- somat 4y agoIf 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.
- jodrellblank 4y ago> “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.
- dotancohen 4y agoIn KDE one can unbind Ctrl-P from print for all KDE apps, from the web browser to the PDF reader to the mail client.
- alexdme 4y agoUgh 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-keys.html 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 https://github.com/alexdavid/keybindings
- bloopernova 4y agoVery cool! 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:"; }
- beembeem 4y agoIf it's anything like readline/Emacs, then: ^ = Control ~ = Escape
- alexdme 4y agoIn this file `~` is meta (option key on macs). Not sure why it's not escape like it is in emacs.
- dotancohen 4y agoOn Linux, Meta is activated on modern keyboards by both ESC and ALT.
- 4y ago
- luxcem 4y agoOn a linux desktop you can have this in GTK applications with the "gtk-key-theme 'Emacs'" settings.
- yepguy 4y agokeyd is a really nice key remapping daemon that supports application-specific remappings. You could use it to emulate readline bindings in Chrome. Or if you can't figure out how to emulate something, at least bind it to noop so it doesn't mess you up any more. https://github.com/rvaiya/keyd https://github.com/rvaiya/keyd
- kevin_thibedeau 4y agoX11 supports all of this with user configurability but the cool kids threw all of it away.
- dolmen 4y agoAnyone using a Mac is probably not using readline but its replacement 'editline'. 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.
- emmelaich 4y agoYou find these all over the place[0]; I often try them and am unsurprised when they work. Have to train myself not to use ^w though. Try to erase word and it closes the window. [0] for example in the quakelive console