You could try putting it in an ftplugin; putting the command in
~/.vim/after/ftplugin/markdown.vim will define your highlight group after the color scheme is loaded on startup.
However, this may break when changing color schemes because color schemes will typically call
:highlight clear to clear any previously defined highlight groups before defining their own. This can cause user highlight groups defined in
.vimrc to be overridden.
To remedy this, you can create an autocommand that will execute a command every time a color scheme is loaded, but you'll need to check the
filetype of the current buffer.
hi SpellBad cterm=underline
autocmd ColorScheme * if &ft ==? 'markdown'
\| highlight SpellBad cterm=underline
\| set spelllang=en_us
It's important to wrap the autocommand in an
augroup to prevent defining the autocommand more than once (if you were to change color schemes, for example).
autocmd! is used to clear any existing autocommands defined for the current
There's also a very informative GitHub gist about overriding color schemes in this way that would be a good read.
Also see the following help pages:
highlight and spelling