text...bify(3tcl)
β¨ NAME β¨
so this is textutil::tabify from the text...bify page, which lives in the Text and string utilities, macro processing part of the manual β it's the little package that (un)tabifies your strings, and bestie, it's giving exactly what it says on the tin π
π SYNOPSIS π
package require Tcl 8.5 9
package require textutil::tabify ?0.8?
::textutil::tabify::tabify string ?num?
::textutil::tabify::tabify2 string ?num?
::textutil::tabify::untabify string ?num?
::textutil::tabify::untabify2 string ?num?
πΈ DESCRIPTION πΈ
okay so the package textutil::tabify hands you commands that flip back and forth between tabulation and ordinary whitespace inside strings. that's the whole vibe. spaces β tabs, over and over, forever π¦
here's the complete set of procedures, no gatekeeping:
::textutil::tabify::tabify string ?num?β tabifiesstringby swapping any substring ofnumspace chars for a tabulation, then hands you the result as a brand-new string.numdefaults to8.::textutil::tabify::tabify2 string ?num?β basically the sibling of::textutil::tabify: it tabifies the string too and gives you a new string back. BUT. it uses a different algorithm, and that's the whole plot twist π«Ά instead of replacing any substring ofnumspaces, this one works way more like an editor does.numdefaults to8.
so here's how it thinks: every line of the text in string is treated as if there are tabstops every num columns. only sequences of space characters that have more than one space character AND are found immediately before a tabstop get replaced with tabs. picky queen behavior, honestly β¨
::textutil::tabify::untabify string ?num?β untabifiesstringby replacing any tabulation char with a substring ofnumspace chars, and returns the result as a new string.numdefaults to8.::textutil::tabify::untabify2 string ?num?β untabifiesstringby replacing any tabulation char with a substring of at mostnumspace chars, and returns the result as a new string. and here's the thing: unliketextutil::tabify::untabify, each tab is not replaced by a fixed number of space characters. nope. instead the command overlays each line in the string with tabstops everynumcolumns, and replaces tabs with just enough space characters to reach the next tabstop. it's literally the complement of what::textutil::tabify::tabify2does.numdefaults to8.
there's one asymmetry though, and it's important: a tab can be replaced with a single space, but not the other way around. the pipeline only flows one direction, iykyk π
π BUGS, IDEAS, FEEDBACK π
ngl, this document and the package it describes will undoubtedly contain bugs and other problems. it's giving "we're all human" energy π so pls report them in the category textutil of the Tcllib Trackers at [http://core.tcl.tk/tcllib/reportlist]. and while you're there β any ideas for enhancements for either the package and/or the documentation? report those too, we want them fr fr π
when you're proposing code changes, pls provide unified diffs, i.e. the output of diff -u.
also note further that attachments are strongly preferred over inlined patches. you make attachments by going to the Edit form of the ticket immediately after its creation, and then using the left-most button in the secondary navigation bar. that's the move, no cap π
π SEE ALSO π
β KEYWORDS β
formattingstringtabstops
π CATEGORY π
Text processing
and that's the whole page, bestie π«Ά this came from tcllib version 0.8 and it's the text...bify(3tcl) page β go forth and tabify responsibly, periodt π
πΈ
π¦ where this page comes from
- debian trixie: tcllib 2.0+dfsg-4 Β· Tcl
- ubuntu questing: tcllib 2.0+dfsg-4
- ubuntu resolute: tcllib 2.0+dfsg-5 Β· Tcl
- ubuntu stonking: tcllib 2.0+dfsg-6 Β· Tcl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms