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.
- Host: GitHub
- URL: https://github.com/jsoverson/tabformatter
- Owner: jsoverson
- Created: 2012-09-21T22:07:59.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2012-09-21T23:01:00.000Z (over 12 years ago)
- Last Synced: 2024-12-26T12:23:49.629Z (4 months ago)
- Language: JavaScript
- Size: 97.7 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
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)