Sometimes when copying code into a textarea to share via slack, discord, wherever, the code will have leading spaces due to the nested/indented nature of the code. This script removes as much leading white space as possible.

Turns this:

<Router>
<Routes>
<Route path="/" element={<Layout />}>
<Route index element={<Home />} />
</Routes>
</Router>

into this:

<Router>
<Routes>
<Route path="/" element={<Layout />}>
<Route index element={<Home />} />
</Routes>
</Router>

Open move-code-left in Script Kit

// Name: Move code left
// Shortcut: cmd shift t
// Author: David Adams
// Twitter: @dadamssg
import "@johnlindquist/kit"
let text = await getSelectedText()
let lines = text.split("\n")
let lineStarts = lines.map(line => line.search(/\S/))
let charsToTrim = Math.min(...lineStarts)
let formatted = lines.map(line => line.substring(charsToTrim)).join("\n")
await setSelectedText(formatted)