Coming from WebStorm and TypeScript land, I got sick of not having auto-formatted code while working on a small Front End SwiftUI project. After finally figuring out how to autoformat my Swift code, I had to share as NO RESULTS ONLINE WERE HELPFUL!
See below and linked video. Let me know if you have any questions or suggestions for improvements.
- brew install nshipster/formulae/swift-format
- Create external tool
- Name it swift-format
- Under Tool Settings > Arguments: --in-place $FilePath$
- Advanced Options > Uncheck Open console for tool output
- Click OK
- Click Apply
- Create a Keymap for your new external tool by searching for “swift-format” and double clicking on the result
- Open any code file
- Edit > Macros > Start Macro Recording
- Invoke the keycap from step 6 and then save your file
- Click the stop button in the bottom right hand of your editor to stop the macro
- LAST STEP Assign the ⌘S keymap to your new macro
Top comments (0)