The OpenD Programming Language

detabber

Replace each tab character in r with the number of spaces necessary to align the following character at the next tab stop.

  1. auto detabber(Range r, size_t tabSize)
  2. auto detabber(Range r, size_t tabSize)
    detabber
    (
    Range
    )
    (
    auto ref Range r
    ,
    size_t tabSize = 8
    )

Parameters

r Range

string or forward range

tabSize size_t

distance between tab stops

Return Value

Type: auto

lazy forward range with tabs replaced with spaces

Examples

import std.array : array;
import std.utf : byChar, byWchar;

assert(detabber(" \u2029\t".byChar, 9).array == " \u2029         ");
auto r = "hel\tx".byWchar.detabber();
assert(r.front == 'h');
auto s = r.save;
r.popFront();
r.popFront();
assert(r.front == 'l');
assert(s.front == 'h');
import std.array : array;

assert(detabber(" \n\tx", 9).array == " \n         x");

Meta