I suspect that it doesn't. I don't see anything about it in the documentation(:h spell), but I'd love to be proven wrong.


Not in the command line that I know of since I'm pretty sure the command line prompt doesn't highlight text. But, you can enable spell checking in the command window.

Press ctrl-f on the command line or press q: in normal mode. This brings up the command window which can be treated almost like any other buffer. From here you can run :set spell to enable spell checking. However, the command window uses filetype=vim which doesn't show spelling errors for some reason. Running set filetype= to disable the syntax highlighting allows the spell check highlight to show.

You can use an autocmd to set up the command window when it opens:

autocmd CmdwinEnter * if &ft =~# 'vim' | setlocal spell ft= | endif

This is a better solution based on your comment below about using input():

autocmd CmdwinEnter * if getcmdwintype() == '@' | setlocal spell | endif

This will enable spellcheck for the input() history window.

From :h cmdwin-char:

The character used for the pattern indicates the type of command-line:
    :   normal Ex command
    >   debug mode command debug-mode
    /   forward search string
    ?   backward search string
    =   expression for "= expr-register
    @   string for input()
    -   text for :insert or :append

If your version of Vim does not have getcmdwintype(), you could use a expression map since getcmdtype() is only available when editing the command line or an expression mapping:

cnoremap <silent><expr> <c-f> getcmdtype() == '@' ? "\<c-f>:setlocal spell\<cr>" : "\<c-f>"
  • Nice! While not a perfect solution this actually works pretty well. I'll wait for a bit to see if anyone has any other ideas, but if not I'll definitely give you the green check :). Side note: I am using the input to an input() command and when I press Ctrl+F there the filetype is already set to nothing. I also have a hot key for turning spell check on so it all works pretty well. – Tumbler41 Jun 21 '16 at 14:24
  • Other note, I think that the vim filetype will do spell checking, but only in strings and comments. (Which is pretty normal as far as spell checking code goes) – Tumbler41 Jun 21 '16 at 14:30
  • @Tumbler41 I saw that in syntax/vim.vim, but I didn't see spell check working in strings and comments when I was testing it. Maybe I have a syntax file overriding it somewhere. – Tommy A Jun 21 '16 at 14:48
  • @Tumbler41 I updated the answer with what I think is better in your case of using input() – Tommy A Jun 21 '16 at 14:59
  • It seems that getcmdwintype() is not installed on my version of vim. Looks like it was added in version 7.4.383 It would appear that I have 7.4.0 (I think although vim --version only says "7.4" grrrrr) Do I have to compile vim to get a patch that isn't a major release? (i.e. 7.5) – Tumbler41 Jun 21 '16 at 16:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.