Overview
What Outdent does
Remove the shared indentation from selected lines. It runs locally and handles the selected text without contacting a service.
| Category | Text Editing & Formatting |
|---|---|
| Action type | JavaScript |
| Default result | Replace selected text by default |
| Internet | Not required |
Example
Action and outcome
| Action | Outcome |
|---|---|
| OutdentSelected text: one two three | one two three |
Workflow
Use Outdent
Follow these steps to remove the shared indentation from selected lines with ActionClip.
- Select the text you want to use.
- Choose Outdent from ActionClip.
- In editable text, ActionClip replaces the selection immediately. In read-only text, it opens the result for review and copying.
Before you add it
Requirements and privacy
- Before you start: No setup required.
- Your selected text: Runs locally in ActionClip’s JavaScript sandbox. Selected text does not leave your Mac.
Inspect before installing
Action script
The script below is included so you can inspect how the action works before downloading it.
JavaScript definition
function run(selected_text) {
var normalized = selected_text.replace(/\r\n?|\u2028|\u2029|\u0085|\u000B|\u000C/g, "\n");
var lines = normalized.split("\n");
var nonBlank = lines.filter(function (line) { return /\S/u.test(line); });
if (nonBlank.length === 0) return normalized;
var width = nonBlank.reduce(function (shortest, line) {
var prefix = (line.match(/^[ \t]*/u) || [""])[0];
return Math.min(shortest, prefix.length);
}, Number.MAX_SAFE_INTEGER);
if (!Number.isFinite(width) || width === 0) return normalized;
return lines.map(function (line) { return /^\s*$/u.test(line) ? "" : line.slice(width); }).join("\n");
}