And the next lesson: C-r will search the command history (at least in most *nix shells). So when needing to do something but you aren't sure how far back it was (not on the screen or not recallable) but you know it is in the history and some text in it, just C-r <something> [C-r repeatedly until you get to the correct version].
This one's my favorite. Not every distribution of readline enables this, so you might need to uncomment or add the binding for history-search-backward/forward into /etc/inputrc or ~/.inputrc. Similarly editrc for programs that use libedit instead of readline to avoid the GPL.
I do this a lot as well. A useful side-tip to go with that: set your bash history size to be unlimited (or at least really big) to avoid losing less frequently used commands.
On Windows, Ctrl+Backspace will delete the word left from the cursor, Ctrl+Delete the word to the right. It's pretty much unknown as far as I'm aware but it has boosted my editing productivity immensely.
Unknown? You can't work inside Windows at all without those shortcuts. In Emacs it's alt+Backspace, so it's not too hard to organically find in other environments by trial and error.
Whenever I switch editors, I quickly look for the following shortcuts:
* How do you delete a word forwards and backwards? (there might be a better shortcut such as Ctrl+W)
* How do you move to the word ahead and the word behind?
* How do you kill a line?
* How do you duplicate a line?
* How do you move a line up and down?
* How do you activate multiple cursors?
* How do you comment/uncomment a line/block?
* How do you expand/contract a selection?
I think that covers about 80% of the common actions, and learning them will make you instantly productive in your new editor.
If it’s readline-based like bash and you are still using default shortcuts then you can do M-b and M-f for backward/forward a word at a time (not sure what the Meta equivalent is on a Mac. On my keyboard it is the ‘Alt’ key.) Many Mac apps/text inputs support emacs-style shortcuts like these.
Some other very handy shortcuts in MS Office programs (and maybe others) is alt-shift-up/down arrow will move the entire line up or down. Quite handy to move text around when composing an email for instance.
Ctrl-up/down will move the cursor past newlines, so you can more quickly navigate when there are long lines with lots of wrapped text.
I got a laugh out of helping a PhD ML researcher who was having problems with their keyboard. They showed me how they had lowered the repeat delay on their wireless mac keyboard, and now when they typed, it went nuts and stayed stuck on repeat randomly. The reason they lowered the delay was that it was taking too long to delete the long command they had (they wanted to hold down delete to clear everything out).
I was able to show them that there was interference from their USB-C dock which likely caused the key up events to be dropped - and that they could also use the option key to delete entire words at a time.
I've always used CTRL+SHIFT+left then backspace. Since I'm used to using ctrl to navigate and skip words, adding the shift modifier just kinda slotted right into my brain
reply