blob: d622f03b0d46c0811eb5575bdac83c7cfd09e491 [file] [log] [blame] [view]
Kaido Kertf585e262020-06-08 11:42:28 -07001# strip-indent [![Build Status](https://travis-ci.org/sindresorhus/strip-indent.svg?branch=master)](https://travis-ci.org/sindresorhus/strip-indent)
2
3> Strip leading whitespace from every line in a string
4
5The line with the least number of leading whitespace, ignoring empty lines, determines the number to remove.
6
7Useful for removing redundant indentation.
8
9
10## Install
11
12```sh
13$ npm install --save strip-indent
14```
15
16
17## Usage
18
19```js
20var str = '\tunicorn\n\t\tcake';
21/*
22 unicorn
23 cake
24*/
25
26stripIndent('\tunicorn\n\t\tcake');
27/*
28unicorn
29 cake
30*/
31```
32
33
34## CLI
35
36```sh
37$ npm install --global strip-indent
38```
39
40```sh
41$ strip-indent --help
42
43 Usage
44 strip-indent <file>
45 echo <string> | strip-indent
46
47 Example
48 echo '\tunicorn\n\t\tcake' | strip-indent
49 unicorn
50 cake
51```
52
53
54## Related
55
56- [indent-string](https://github.com/sindresorhus/indent-string) - Indent each line in a string
57
58
59## License
60
61MIT © [Sindre Sorhus](http://sindresorhus.com)