5 ms·
Unit Separator is Control-_ (underscore) and Record Separator is Control-^ (caret), for instance. Most modern text editors won't pass through every control cha
by thwarted 13y ago
Unit Separator is Control-_ (underscore) and Record Separator is Control-^ (caret), for instance.
Most modern text editors won't pass through every control character. Vim lets me type the unit separator, but not the record separator, for instance.
Vim has bindings for some control key combos, which is why you can't type them directly. I can type control-_ without issue, but to get an ASCII 30 (RS) to show up, I have to type control-v first (just like when at the shell prompt).
Useful hint: if you look at the output of man ascii (at least on linux with man-pages-3.22) find the control character you want to type in the left column and look in the same row on in the right column to find the letter/key to use with the control key.
For example, to type NAK, it's <control-u>. Vertical tab is <control-k>:
$ echo <control-v><control-k> | od -c
0000000 \v \n
This is useful for control characters that don't have backslash escape expansions.
- raldi 13y ago...and that's why, when running a command that's reading what you're typing to stdin, you press Ctrl-D to tell it that you're done. Because, as your "man ascii" trick shows, this generates the "end of transmission" character. Similarly, Ctrl-L clears the screen in most Unix apps because that generates the "form feed" character, and on a line printer or paper-based teletype terminal, "form feed" means to advance to the next page -- a nice empty clear piece of paper.
- sopooneo 13y agowhat about Ctrl-C to break out of stuff? Does that correspond to an ascii control character?
- elwin 13y agoCtrl-C stops the program because the TTY driver watches for it and sends an interrupt signal when it appears. It's a slightly different mechanism. There are more details in "man 3 termios", but be warned, the TTY layer is not a pleasant subject for reading.
- jloughry 13y agoCtrl-C was originally "End of Text".
- danielweber 13y agoI was disappointed that Ctrl-S and Ctrl-Q don't correspond (at least on the first ASCII chart I googled) to anything, because Ctrl-S stops text on my Unix terminals the exact same way it did on my brother's Apple ][e in 1984.
- jrochkind1 13y ago> I was disappointed that Ctrl-S and Ctrl-Q don't correspond (at least on the first ASCII chart I googled) to anything I'm pretty sure every possible combination of 7-bits is assigned SOME name in ascii, and Ctrl-any-case-insensitive-letter is a defined 7bit value. This chart says control-s is `DC3 (Device Control, X-OFF)` and control-q is `DC1 (Device Control, X-ON)`. Yup, that's what they do alright. http://www.unix-manuals.com/refs/misc/ascii-table.html http://www.unix-manuals.com/refs/misc/ascii-table.html Don't forget everyone's favorite control-G, BEL, useful sending beeps across the wire on old school IRC, BBSen, and chat services. Or, you know, telegraph machines or something.
- csixty4 13y agoFor anyone wondering, X-ON and X-OFF are flow control characters. A device sends X-OFF to say "my buffer is full, stop sending data" and X-ON when it's ready to resume. On most Unix terminals, these have the effect of pausing and resuming the display when a bunch of data is scrolling by.
- __del__ 13y ago...and they're helpfully disabled with stty -ixon
- danielweber 13y agoOh, thank you. The reference I found[1] only showed them as "device control." I thought I imagined them having that. Also, the classic control-G is still in C. "\a" is "alert (beep)." [1] http://www.asciitable.com/ http://www.asciitable.com/
- fineline 13y ago
- thwarted 13y agowhen running a command that's reading what you're typing to stdin, you press Ctrl-D to tell it that you're done. Because, as your "man ascii" trick shows, this generates the "end of transmission" character. This is slightly different than being able to actually generate those characters as input. If you put a control-d in a file, nothing will stop reading the file when it sees the control-d, it's just another byte. readline knows how to interpret a bunch of control characters. There's also the terminal driver that has interpretations, which you can see with `stty -a`. When the tty layer sees a control-d or a control-c, it closes stdin or generates SIGINT, respectively. But even this can be dependent on if you're on a pty or attached directly to a serial line. There's nothing special about the mapping of control-d to end-of-transmission character, that's just how the layer that sees it is interpreting it. You can, for example, change how control-c is interpreted by `stty intr ^B`, which will make control-b generate SIGINT. And there's a way to put the terminal driver in complete transparent/passthru mode.
- raldi 13y agoSure, the default is overridable, and the character has no magic effect when found in a binary file, but there's a reason Ctrl-D was chosen as the standard keystroke sequence to end a stdin transaction, and it has everything to do with the fact that "D" shows up next to "end of transmission" in `man ascii`.
- thwarted 13y agoThank you for clarifying something that no one was disputing or event mentioned.
- qu4z-2 13y agoYeah, I hate it when people point out interesting things I didn't know before too.
- thwarted 13y agoI'm sure raldi can repeat, again, making it 3 times, that control-d means end of transmission and that's why it was chosen for signalling end of stdin, on a thread about how to type the control characters.
- oneeyedpigeon 13y agoI am going to love not having to type out 'clear' all the time - thank you!
- dhimes 13y agoThat's a terrific hint. So the ctrl-<dec-val + 64 char> = <dec val char>