0

I always thought \t as a character, and never realize they are used by terminals for column/field alignment, until Stephane said What does `pr -e` mean?

printf '%b' '\t' or printf '\t' writes a TAB character to its stdout. If that's written to a tty device with a terminal at the other end, that terminal will receive the TAB character and move its cursor to the next tab stop (start of the next table cell if you want).

when can I view \t as a character which spans a fixed width, instead of a control character which jumps to the next tab stop?

Also In Emacs, the behaviour of TAB seems neither jumping to the next tab stop nor a character spanning a fixed width.

Thanks.

Tim
  • 98,580
  • 191
  • 570
  • 977
  • 1
    If you mean *how*, then it's easy -- something like `sed -e 's/\t/▫▫▫▫/g'` `| less` should do it. If you really meant *when*, then it don't understand what kind of answer you are expecting. – AlexP Jul 30 '18 at 18:12
  • In emacs, the tab character does usually jump to next tab stop. However this is not usually what the «tab» key does. To insert a tab character press «ctrl»-q «tab» – ctrl-alt-delor Jul 30 '18 at 19:14
  • @ctrl-alt-delor in emacs, the tabstops are not equally spaced, see the example in the link. Or am I misunderstanding your comment? – Tim Jul 30 '18 at 19:18
  • @Tim in your Emacs example you’re *typing* Tab. In Emacs, the Tab key isn’t handled in the same way as the character. A Tab character always aligns to the next tab stop, but pressing the Tab key doesn’t necessarily insert a single Tab character — it will insert whatever the invoked function determines should be inserted. – Stephen Kitt Jul 31 '18 at 06:43

0 Answers0