Xcode spell checking
Asked Answered
B

9

49

Just wondering if there is a way to enable spell checking in Xcode. Maybe an add-on or something...

Banuelos answered 23/4, 2010 at 8:3 Comment(0)
F
49

You turn on spelling from the Edit menu (right at the bottom).

Edit: For code files, there's always the compiler, although that won't check comments, and won't stop you from spelling things wrong; it'll only stop you from spelling things inconsistently.

Reedit: In the 4 years since this was posted, the spell checker has moved a little: It is now under Edit > Format > Spelling and Grammar. Format is near, but not at the bottom.

Flieger answered 23/4, 2010 at 8:11 Comment(7)
Xcode seems to only allow you to check text files (.txt, .rtf). How can you enable spell checking for source files (.h, .cpp, ...) so you can check your comments and embedded documentation?Hydrosol
You can copypaste them out into txt files, or you could just proofread them manually.Flieger
@WillihamTotland, "right at the bottom" is so misleading :|Nuris
"Right at the bottom" is "Special Characters..."Vibrant
Do you know how to change the language? The dictionary it's using is for British English, and I'd prefer American English.Hound
Never mind, I think I've found it, indirectly via the first answer on this thread: #35464030 In the Spelling drop-down box instead of "Automatic by language" you can select the language you want.Hound
As I noted in my answer below, Xcode 11.3.1, does what you want in code. After additional use, I am very happy with the feature and will keep it enabled.Brocklin
S
17

In Xcode 4.5 you need to choose: Edit -> Format -> Spelling and Grammar -> Check Document Now (cmd + ;)

Scrivenor answered 8/10, 2012 at 8:23 Comment(3)
I did check once again and it worked. Try to use short cut: cmd + ;Scrivenor
It checks the variable spellings, I wanted to check the hardcoded strings. do you know a good plugin for thisFulfill
For me it works. I wrote: let str = "Cobrass" and used cmd + ; it marked as wrong spelling.Scrivenor
S
11

Put the cursor infront of your comment and press cmd ; this will jump to the next misspelt word.

Shackleton answered 6/3, 2012 at 12:54 Comment(0)
I
8

For Xcode11 & Xcode12, adding the screenshot for quick reference:

Some Tips:

  • Use the keyboard shortcut: + ; together to move the cursor to the next spelling error.

  • Tapping on ; while holding cycles through all misspelled words.

  • shift + + ; to edit known words

XCode11 Spelling and Grammer Edit menu option

Impersonate answered 24/8, 2020 at 21:42 Comment(1)
I love how much work people put into useless censorship. Imagine the world knew those blanked out method names!Weider
K
6

You can also do: Edit > Format > Spelling and Grammar > Check Spelling While Typing. (Xcode 4.6.3)

Knopp answered 13/1, 2014 at 4:28 Comment(1)
Why it's not enabled for me ??Basket
M
6

Spell checking was broken in Xcode 9 and 10. It's now fixed in Xcode 11.0.
(Edit ► Format ► Spelling and Grammar ► Check Document Now)


Original answer below:

Unfortunately it doesn't work in Xcode 9 and 10. I posted a bug to Apple using "Bug Report". And it was marked as a dupe of a bug with number "32062963". And I found it here.

So if you want it works, PLEASE, POST A BUG! here.

Apple uses this to gauge how serious a bug is.

As it was mentioned here by Donarb.

Mechanic answered 7/11, 2018 at 10:9 Comment(1)
Hello from Sep 2019. I thought you might be interested that the bug in now fixed in Xcode 11.0.Consalve
B
2

As of Xcode 11 (tested in 11.3.1), if you turn on "Check spelling while you type", found in the Edit->Format->Spelling and Grammar menu, Xcode will display the red word spelled wrong indicator for comments as they are spelled wrong. It will also spell check camel case identifiers (much to my surprise). I am only just now using this so I don't know the sharp corners but it is exciting. As someone that is bilingual, I find myself mangling words. You can also set the preferred language using the "Show spelling and Grammar" option.

Image showing Xcode spelling errors indicators

Brocklin answered 22/2, 2020 at 18:57 Comment(0)
C
1

The Scribe plugin can do that (among other things). It's smart enough not to spell check code so you don't get a lot of false positives, and you can also right-click to get spelling suggestions.

Full disclosure: I'm the author of the plugin.

Crutcher answered 6/11, 2015 at 15:14 Comment(1)
Unfortunately, Xcode 8 introduced a watered-down plugin framework and removed support for old plugins, so Scribe only works in Xcode 7.Crutcher
C
0

As of Xcode 15 you can enable global spell checking by going to Edit menu > Format > Spelling and Grammar > Check Spelling While Typing. Such global check if off by default, but I see no downside to turning it on, only benefits.

If you do Xcode will highlight every typo with a red underline, both in comments and in camelCase variable and function names. And even suggest corrections.

Alternatively you can do a step-by-step spell check with + ;.

UPD: Other cases such as snake_case, PascalCase, and kebab-case are also checked, but for Swift camelCase is the default one.

Crassus answered 3/10, 2023 at 14:30 Comment(1)
Downside is it makes editing lag.Weider

© 2022 - 2024 — McMap. All rights reserved.