Hacker Read top | best | new | newcomments | leaders | about | bookmarklet login

Huh? Backspace works the same for me in Bash C-r as it does in Emacs C-r.


sort by: page size:

> Backspace is just backspace

Unless you're on the wrong terminal. (google "emacs fix backspace")

Besides, it's really a big deal that most applications in your system use one set of hotkeys, while bash and emacs use a totally different one.


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?

No, at least for me (Firefox on Linux) Backspace doesn't do anything special.

Actually backspace is the equivalent of pushing the back button. Which is often similar but can give different results. Boy I miss OSX sometimes :)

[1]

> 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.



CTRL-h doesn't behave the same as backspace on OS-X. This makes it hard to use for me. Cool idea though.

the backspace thing is I think configurable based on your terminal or using stty to do it.

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.)

https://www.gnu.org/software/emacs/manual/html_node/efaq/Bac...

https://www.gnu.org/software/emacs/manual/html_node/emacs/DE...


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 suspect it was a remnant of hardcopy terminals


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.


Interesting. That absolutely doesn't work on my machine (2015 Macbook Pro, Catalina, latest Chrome). Backspace simply does nothing.

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, thanks for that! I’m still missing backspace to go back sometimes, but I never knew about this. On Windows it’s alt+left.

> There's no way to type a backspace without literally pressing backspace :)

ctrl-H usually works.


I never knew of any backspace shortcuts. Are you referring to one in specific?

Installed this from the AUR and tried it. Sadly I can't backspace, since it doesn't support using ^? for backspace, only ^H.

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.
next

Legal | privacy