An open API service indexing awesome lists of open source software.

https://github.com/jsoverson/tabformatter

Simple util to replace tabs accurately in a multiline string.
https://github.com/jsoverson/tabformatter

Last synced: 2 months ago
JSON representation

Simple util to replace tabs accurately in a multiline string.

Awesome Lists containing this project

README

        

TabFormatter
============================

A simple utility method that strips
out tab characters from multi line strings
and replaces them with any arbitrary string.

Not elegant, purely useful

## Usage
```
TabFormatter.format(
string,
numChars,
replacementString || ' ',
replacementStringWidth || 1,
prefix || '',
suffix || ''
);
```

```
TabFormatter.format("\tvar b;\t//Hi!", 4);
// -> " var b; //Hi!"
TabFormatter.format("\tvar b;\t//Hi!", 4, ' ', 1);
// -> "    var b;  //Hi!"
TabFormatter.format("\tvar b;\t//Hi!", 4, ' ', 1, '','');
// -> "    var b;  //Hi!"
```

### Why?

Wanted to write a blog post about tabs v spaces
and replacing tabs turned out to be more than the
single liner I hoped. So unit tests!

### Author

Jarrod Overson - [jarrodoverson.com](http://jarrodoverson.com)