How does one add a word containing a slash to one’s vim spell dictionary file

spell-checkvim

I am trying to do:

:spellgood w/o

I get an error message saying

Unrecognized flags in ~/.vim/spell/en.utf-8.add line 16

I have attempted the following to no avail:

:spellgood w\/o
:spellgood w//o
:spellgood "w/o"
:spellgood 'w/o'

I also tried visually selecting the word in question and hitting zg. Same error.

How can I get vim to stop telling me that w/o is a bad word?

Adding o to the spell file or capitalizing w/o to W/O works, but those options make me sad.

Update

I have added the following as ~/.vim/spell/en_US.aff

SET ISO8859-1
KEY qwertyuiop|asdfghjkl|zxcvbnm
TRY esianrtolcdugmphbyfvkwzESIANRTOLCDUGMPHBYFVKWZ'-
NOSUGGEST !

# ordinal numbers (1st, 2nd, 3th, 11th) and decads (0s, 10s, 1990s)
COMPOUNDMIN 1
# only in compounds: 1th, 2th, 3th
ONLYINCOMPOUND c
# compound rules:
# 1. [0-9]*1[0-9]th (10th, 11th, 12th, 56714th, etc.)
# 2. [0-9]*[02-9](1st|2nd|3rd|[4-9]th) (21st, 22nd, 123rd, 1234th, etc.)
COMPOUNDRULE 2
COMPOUNDRULE n*1t
COMPOUNDRULE n*mp
WORDCHARS 0123456789' 

and the following file as ~/.vim/spell/en_US.dic

1
w\/o

and have executed the following vim commands:

:cd ~/.vim/spell
:mkspell mine en_US.aff
:set spelllang+=mine
:spellinfo
file: ~/.vim/spell/en.utf-8.spl
file: ~/.vim/spell/mine.utf-8.spl
file: ~/.vim/spell/en.utf-8.add.spl

And I still cannot get vim to recognize w/o as a good word.

Best Answer

From :help spell

Note: in line 5 to 7 non-word characters are used. You can include any character in a word. When checking the text a word still only matches when it appears with a non-word character before and after it. For Myspell a word starting with a non-word character probably won't work.

In line 12 the word "TCP/IP" is defined. Since the slash has a special meaning the comma is used instead. This is defined with the SLASH item in the affix file, see |spell-SLASH|. Note that without this SLASH item the word will be "TCP,IP".

Above it defines some custom words, TCP/IP being one of them. So you should just need to use , instead of / in this case.

i.e. use w,o

Edit

As you point out, I was pointing toward documentation about .dic files, which in my limited experience are more common. In the .dic file, you can use your solution of w\/o (see :help spell-SLASH)

WORDS WITH A SLASH                                      *spell-SLASH*

The slash is used in the .dic file to separate the basic word from the
affix letters and other flags.  Unfortunately, this means you cannot
use a slash in a word.  Thus "TCP/IP" is not a word but "TCP with the
flags "IP".  To include a slash in the word put a backslash before it:
"TCP\/IP".  In the rare case you want to use a backslash inside a word
you need to use two backslashes. Any other use of the backslash is
reserved for future expansion.
Related Question