https://troglobit.com/projects/editline/
See also the note at the bottom of that page about other versions of editline/libedit.
51–60 of 174 posts
https://troglobit.com/projects/editline/
See also the note at the bottom of that page about other versions of editline/libedit.
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
If we're counting ^C, then I'd also add: * ^D - Send EOF, which exits most shell-like programs (if you're on an empty line, so try ^C^D) And the job control bindings: * ^Z - Suspend current foreground process and return to shell, use `fg` to resume it in foreground and `bg` to resume it in background (see also `disown`) * ^S - "Stop" current process, useful if it's printing a lot of stuff and you want to pause it for…
> C-e, C-f, M-b, M-f Why these strange shortcuts when any keyboard has arrow keys and they can be used with a control modifier to move by words? I can understand why to use C-a, C-e, because laptop keyboards tend to have "Home" and "End" keys in strange places, but those... And Emacs documentation for some reason insists on using C-e, C-f instead of arrow keys.
They work everywhere. Decades ago, the Home/End/PgUp etc keys might not work on all terminals. You can use the standard keyboard movement keys if you prefer. (The letters are mnemonics, Back, Forward, Next line, Previous line, End of line, start of line uses A as the first letter. The control key tends to do smaller things (like move one letter or line) while the alt/meta key does bigger or less-common things, like m…
Decades ago, on real serial terminals, the terminal keyboard likely did not even have Home/End/PgUp/PgDn keys [1].
That is the reason for the seeming odd mappings now in 2022 after almost every computer has a keyboard that contains nearly the same set of 'extra' keys. When readline was developed, there was no IBM-PC keyboard layout (because readline predates the IBM-PC) and besides the basic letters, numbers and punctuation keys there were very few other keys that were available on all keyboards at the time.
[1] https://en.wikipedia.org/wiki/File:Mappa_Teletype_ASR-33.jpg
https://vt100.net/docs/vt100-ug/chapter3.html (see "The Keyboard")
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…
Earlier quoted context omitted.
So, to be fair , C-h isn't some crazy invention of readline (and thereby a failure of what it was "advertising") that you got used to: it is the standard key code for backspace. Just like a horizontal tab is ASCII 9 and a carriage return is ASCII 13, ASCII 8--and I realize this might make less sense as this in some sense "undoes" a thing and maybe you would never expect it to be in a file--is backspace. Meanwhile, al…
Don't mean to be pedantic, but this comment left me very confused, surely you mean carriage return to be ASCII 13? Also, g is the 7th character and BEL is 7.
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-e, C-f, M-b, M-f Why these strange shortcuts when any keyboard has arrow keys and they can be used with a control modifier to move by words? I can understand why to use C-a, C-e, because laptop keyboards tend to have "Home" and "End" keys in strange places, but those... And Emacs documentation for some reason insists on using C-e, C-f instead of arrow keys.
The reason you use them is that they allow you to not leave the home row. So say you're writing something and need to move back and delete a mistype, it's much faster to do that with C-b C-b C-b backspace M-f than moving your right hand to the arrow keys and moving it back to type the letter and then moving it to the arrow keys again.
Now, lot's of people can't be bothered to take the time to learn them. You need to go through the Emacs tutorial and perhaps spend a day or two getting used to them. That's all it takes.
Similarly, most programmers I personally know can't touch type. That takes a few hours of practice with a fun, gamified touch typing program for a couple of weeks, and then you have set part of your mind free. But people can't be bothered.
> C-e, C-f, M-b, M-f Why these strange shortcuts when any keyboard has arrow keys and they can be used with a control modifier to move by words? I can understand why to use C-a, C-e, because laptop keyboards tend to have "Home" and "End" keys in strange places, but those... And Emacs documentation for some reason insists on using C-e, C-f instead of arrow keys.
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.
After getting very used to C-w (delete back work) and C-h (delete character backward) on readline, it really bugged me that these aren't default on emacs, even though readline is often advertised as giving emacs muscle memory. I ended up globally remapping C-w and moving the help prefix, C-h to C-x h and making C-h backspace, because i was pressing it incorrectly that often.
So, to be fair , C-h isn't some crazy invention of readline (and thereby a failure of what it was "advertising") that you got used to: it is the standard key code for backspace. Just like a horizontal tab is ASCII 9 and a carriage return is ASCII 13, ASCII 8--and I realize this might make less sense as this in some sense "undoes" a thing and maybe you would never expect it to be in a file--is backspace. Meanwhile, al…
Subtracting 64 is exactly the same as "masking out a bit". The difference between the control characters and their upper case equivalents is that bit 6 (counting from zero) of the byte is zero for the control characters and is one for the upper case equivalents.
On old terminals, the 'control' key more often than not worked by simply forcing bit six of the character mapped to a given key to zero (i.e., it was a direct hardware change).
Another seemingly little known fact, for ASCII, the difference between upper case and lower case letters is again a single bit. Letter A is 65, letter a is 97, the difference there is bit 5 (counting from zero) is zero for "A" and one for "a".