| Kaido Kert | f585e26 | 2020-06-08 11:42:28 -0700 | [diff] [blame] | 1 | # strip-indent [](https://travis-ci.org/sindresorhus/strip-indent) |
| 2 | |
| 3 | > Strip leading whitespace from every line in a string |
| 4 | |
| 5 | The line with the least number of leading whitespace, ignoring empty lines, determines the number to remove. |
| 6 | |
| 7 | Useful 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 |
| 20 | var str = '\tunicorn\n\t\tcake'; |
| 21 | /* |
| 22 | unicorn |
| 23 | cake |
| 24 | */ |
| 25 | |
| 26 | stripIndent('\tunicorn\n\t\tcake'); |
| 27 | /* |
| 28 | unicorn |
| 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 | |
| 61 | MIT © [Sindre Sorhus](http://sindresorhus.com) |