Disable auto replacement of punctuation in SwiftUI TextEditor

Viewed 150

I am using a SwiftUI TextEditor view, on macOS 11, to edit some snippets of code. It changes punctuation as you type, which might be fine in English text, but is bad for code. For example, it changes -- (two hyphens) to — (a dash), and inserts slanted quotation marks and other things.

How do I make the TextEditor work like a code editor, where you have all that stuff turned off?

This is what I have now:

TextEditor(text: $content)
    .font(Font.system(.body, design: .monospaced))
    .disableAutocorrection(true)
0 Answers
Related