indent-string
Version:
Indent each line in a string
67 lines (39 loc) • 1.13 kB
Markdown
> Indent each line in a string
```sh
npm install indent-string
```
```js
import indentString from 'indent-string';
indentString('Unicorns\nRainbows', 4);
//=> ' Unicorns\n Rainbows'
indentString('Unicorns\nRainbows', 4, {indent: '♥'});
//=> '♥♥♥♥Unicorns\n♥♥♥♥Rainbows'
```
Type: `string`
The string to indent.
Type: `number`\
Default: `1`
How many times you want `options.indent` repeated.
Type: `object`
Type: `string`\
Default: `' '`
The string to use for the indent.
Type: `boolean`\
Default: `false`
Also indent empty lines.
- [indent-string-cli](https://github.com/sindresorhus/indent-string-cli) - CLI for this module
- [strip-indent](https://github.com/sindresorhus/strip-indent) - Strip leading whitespace from every line in a string
- [redent](https://github.com/sindresorhus/redent) - Strip redundant indentation and indent the string
MIT © [Sindre Sorhus](https://sindresorhus.com)