# Trim Lines

> Removes spaces and tabs at the start and end of every line

Version: 1.0.0 · By Deck

- Install in Deck: deck://install-plugin?id=trim-lines&url=https%3A%2F%2Fgithub.com%2Fyuzeguitarist%2Fdeck-plugins%2Freleases%2Fdownload%2Fplugins%2Ftrim-lines-1.0.0.zip
- Download .zip: https://github.com/yuzeguitarist/deck-plugins/releases/download/plugins/trim-lines-1.0.0.zip
- View on GitHub: https://github.com/yuzeguitarist/deck-plugins/tree/main/plugins/trim-lines

Or install with Terminal: 

```sh
mkdir -p ~/.deck/scripts/trim-lines && curl -fsSL https://github.com/yuzeguitarist/deck-plugins/releases/download/plugins/trim-lines-1.0.0.zip | tar -xf - -C ~/.deck/scripts/trim-lines
```

## Script

```js
// Removes spaces and tabs at the start and end of every line.
function transform(input) {
  const lines = String(input ?? "").replace(/\r\n?/g, "\n").split("\n");
  return lines.map((line) => {
    let start = 0;
    let end = line.length;
    while (start < end && (line[start] === " " || line[start] === "\t")) start += 1;
    while (end > start && (line[end - 1] === " " || line[end - 1] === "\t")) end -= 1;
    return line.slice(start, end);
  }).join("\n");
}
```

---

- HTML: https://deckclip.app/plugins/trim-lines
- 中文: https://deckclip.app/zh-cn/plugins/trim-lines.md

© 2026 Yuze Pan
