Haha. I'm an avid vim user and I don't get backspace. The normal key to move back by character is in the home-row. Why would I use backspace instead? Am I missing something?
> In some unusual cases, Emacs gets the wrong information from the system, and <Backspace> ends up deleting forwards instead of backwards.
[2]
That's not the case with the GUI version because it works like any other application (File->Quit or the [x] button). In terminal it's a bit different but it's not like vim is any easier here.
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, all Control does is convert a normal (capital) character into a control character, which is the term for the ASCII characters below 32 (aka, the space character) by essentially subtracting 64 (which is almost but not quite equivalent to masking out a bit). Notably, @ is 64, so C-@ generates ASCII 0, which is why you see ^@ printed for NUL bytes in many editors (including vim). After @, you get A-Z and then [, \, ], ^, and _.
This is why, if you want to get Escape, you can type C-[, as ESC is 27 and [ is 91. And this is also how C-G becomes that annoying bell, because G is the 7th letter of the alphabet and BEL is 7, And so, C-M is equivalent to pressing Enter, C-J is equivalent to pressing Tab... and C-H is equivalent to pressing Backspace!! Now, there is also a DEL, for the Delete key, which is which is 127. As ASCII is designed for 7-bit, that is the same as -1, so you can type it using C-?, as ? is 63 ;P.
OK, so, one might should then wonder how the hell Emacs even works, if they remapped the character code for Backspace to do something silly like Help... right?! And the answer is kind of "it doesn't", which I find amazing! There is actually a FAQ entry for Emacs "Why does the Backspace key invoke help?" and a related section from its manual on "If DEL fails to delete". (It might even be the solution you came up with isn't the ideal one, so you might want to read these.)
thank goodness. I remember it was common that the login screen on a terminal would be configured for # as backspace while backspace would actually DO a backspace but be entered into the buffer.
I wasn't quite aware of this because there are slight inconsistencies in some programs and between OSs.
e.g. in powershell on Windows, Ctrl+Backspace deletes the word part, but in cmd shell, Ctrl+Backspace deletes until whitespace. The keybindings to delete word also vary on Windows vs MacOS (Alt+Backspace deletes a word on mac, but deletes the whole line on Windows. Windows uses Ctrl+Backspace for that).
I was also confused since by-default Emacs doesn't treat `_` as a word character.
This article caught me off guard, because the last one seemed to come from a place of knowledge. I thought a lot of how backspace worked was something that every programmer whose ever written a terminal program has experienced at least once. We faced this during a 300 level System Programming class while implementing a simple shell. Is this not something everyone with a CS background experiences? I guess you could miss it if you never go lower than javascript, or never try to do same line reprinting ie for text based progress bars
Well, that's emacs for you. Everyone gravitates to different bits.
Yes, backward-kill-word would be excellent. I have C-backspace bound to that in Emacs, but I also have a Kinesis keyboard, so C-backspace is just as easy to type as C-w.
Huh? In insert mode, the backspace does what it does in all editors. We're referring to the behavior in normal mode, where backspace is equivalent (I think?) to 'h', or left arrow in most editors.
reply