Last active
September 13, 2022 18:50
-
-
Save dadamssg/4622259964601dbffa9235a5d7ea8d11 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment