5

I'm trying to use spell but for some reason it doesn't work. Here's what I've tried:

  • :setlocal spell spelllang=en_us.
  • :set spell spelllang=en_us.
  • Using a simple text file instead of the .md file I was trying to spell check. Simple file
  • Reverting back to the default theme using :colo default.

.vimrc

call plug#begin()
Plug 'mattn/emmet-vim'
Plug 'wordijp/vim-react-templates'
Plug 'preservim/nerdtree'
Plug 'jiangmiao/auto-pairs'
Plug 'prettier/vim-prettier', { 'do': 'yarn install' }
Plug 'MarcWeber/vim-addon-mw-utils'
Plug 'tomtom/tlib_vim'
Plug 'garbas/vim-snipmate'
Plug 'rakr/vim-one'
Plug 'vim-syntastic/syntastic'
Plug 'tpope/vim-commentary'
Plug 'tpope/vim-surround'
Plug 'leafgarland/typescript-vim'
Plug 'dpelle/vim-LanguageTool'
Plug 'junegunn/vim-emoji'
Plug 'https://gitlab.com/gi1242/vim-emoji-ab.git'
call plug#end()

set path+=**
set shiftwidth=2
set tabstop=2
set expandtab
set autoindent
set smartindent
set nu
set rnu
set showcmd
set wildmenu
set wildmode=list:full
set so=999
set termguicolors
set wildignore+=**/node_modules/**
set shortmess-=S " https://stackoverflow.com/a/58886067/
set background=dark
set completefunc=emoji#complete

au BufWritePre * %s/\s\+$//e
au FileType css set omnifunc=csscomplete#CompleteCSS
au BufRead,BufNewFile *.rt set filetype=reacttemplate
au FileType markdown runtime macros/emoji-ab.vim

colorscheme one

map <C-n> :NERDTreeToggle<CR>

let g:languagetool_jar='/opt/LanguageTool-5.1/languagetool-commandline.jar'

vi --version

VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Oct 13 2020 15:49:09)
Included patches: 1-1453
Modified by [email protected]
Compiled by [email protected]
Huge version with GTK3 GUI.  Features included (+) or not (-):
+acl               +farsi             +mouse_sgr         -tag_any_white
+arabic            +file_in_path      -mouse_sysmouse    +tcl
+autocmd           +find_in_path      +mouse_urxvt       +termguicolors
-autoservername    +float             +mouse_xterm       +terminal
+balloon_eval      +folding           +multi_byte        +terminfo
+balloon_eval_term -footer            +multi_lang        +termresponse
+browse            +fork()            -mzscheme          +textobjects
++builtin_terms    +gettext           +netbeans_intg     +timers
+byte_offset       -hangul_input      +num64             +title
+channel           +iconv             +packages          +toolbar
+cindent           +insert_expand     +path_extra        +user_commands
+clientserver      +job               +perl              +vertsplit
+clipboard         +jumplist          +persistent_undo   +virtualedit
+cmdline_compl     +keymap            +postscript        +visual
+cmdline_hist      +lambda            +printer           +visualextra
+cmdline_info      +langmap           +profile           +viminfo
+comments          +libcall           -python            +vreplace
+conceal           +linebreak         +python3           +wildignore
+cryptv            +lispindent        +quickfix          +wildmenu
+cscope            +listcmds          +reltime           +windows
+cursorbind        +localmap          +rightleft         +writebackup
+cursorshape       +lua               -ruby              +X11
+dialog_con_gui    +menu              +scrollbind        -xfontset
+diff              +mksession         +signs             +xim
+digraphs          +modify_fname      +smartindent       +xpm
+dnd               +mouse             +startuptime       +xsmp_interact
-ebcdic            +mouseshape        +statusline        +xterm_clipboard
+emacs_tags        +mouse_dec         -sun_workshop      -xterm_save
+eval              +mouse_gpm         +syntax            
+ex_extra          -mouse_jsbterm     +tag_binary        
+extra_search      +mouse_netterm     +tag_old_static    
   system vimrc file: "$VIM/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
      user exrc file: "$HOME/.exrc"
  system gvimrc file: "$VIM/gvimrc"
    user gvimrc file: "$HOME/.gvimrc"
2nd user gvimrc file: "~/.vim/gvimrc"
       defaults file: "$VIMRUNTIME/defaults.vim"
    system menu file: "$VIMRUNTIME/menu.vim"
  fall-back for $VIM: "/usr/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_GTK  -pthread -I/usr/include/gtk-3.0 -I/usr/include/at-spi2-atk/2.0 -I/usr/include/at-spi-2.0 -I/usr/include/dbus-1.0 -I/usr/lib/x86_64-linux-gnu/dbus-1.0/include -I/usr/include/gtk-3.0 -I/usr/include/gio-unix-2.0/ -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/pango-1.0 -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libpng16 -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -Wdate-time  -g -O2 -fdebug-prefix-map=/build/vim-EfP9JP/vim-8.0.1453=. -fstack-protector-strong -Wformat -Werror=format-security -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1       
Linking: gcc   -Wl,-E  -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now -Wl,--as-needed -o vim   -lgtk-3 -lgdk-3 -lpangocairo-1.0 -lpango-1.0 -latk-1.0 -lcairo-gobject -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0 -lSM -lICE -lXpm -lXt -lX11 -lXdmcp -lSM -lICE  -lm -ltinfo -lnsl  -lselinux  -lacl -lattr -lgpm -ldl  -L/usr/lib -llua5.2 -Wl,-E  -fstack-protector-strong -L/usr/local/lib  -L/usr/lib/x86_64-linux-gnu/perl/5.26/CORE -lperl -ldl -lm -lpthread -lcrypt  -L/usr/lib/python3.6/config-3.6m-x86_64-linux-gnu -lpython3.6m -lpthread -ldl -lutil -lm -L/usr/lib/x86_64-linux-gnu -ltcl8.6 -ldl -lz -lpthread -lm     

Some Environmental Specs

OS: Linux Mint 19.1 Tessa x86_64
Shell: bash 4.4.20
DE: Cinnamon 4.0.10
Terminal: gnome-terminal
3
  • 3
    Might be helpful to narrow it down: How to debug my vimrc
    – D. Ben Knoble
    Nov 22, 2020 at 16:38
  • 1
    Note that in your example there don't seem to be any misspelled words ("bod" is a valid English word; mostly English slang for "body"). Nov 23, 2020 at 7:41
  • I know this is now old but I just ran into this problem and this is what happened in my case. There was a typo which resulted in a `` block not being closed which means that things past it would be in code so not spellchecked! So for anyone who runs into this problem with a markdown file check that as well. Fortunately my eyes zoom in on typos (it was not my typo).
    – Pryftan
    Jan 31, 2023 at 12:16

3 Answers 3

2

Thanks to @D. Ben Knoble's comment I was able to see the source of the issue:

Warning: Cannot find word list "eng.utf-8.spl" or "eng.ascii.spl"

To solve the problem:

  1. I looked for the files locally
locate en.utf-8

which gave me these results:

/usr/share/vim/vim80/spell/en.utf-8.spl
/usr/share/vim/vim80/spell/en.utf-8.sug
  1. Then copied the .spl file to ~/.vim/spell as suggested here.
cp /usr/share/vim/vim80/spell/en.utf-8.spl ~/.vim/spell

I still can't see the errors highlighted when I load the .vimrc (though the errors are findable using ]s/[s), but that's another issue.

3
  • I know this is old but the likely reason you can't see the highlighted misspelt words is you don't have the proper highlight options. Try: :help on spelllocal, spellrare, spellcap and spellbad. And you might want to do it on spelllang (or spl) as well. Hope that helps even if late in the coming!
    – Pryftan
    Mar 24, 2022 at 9:58
  • Oh you might also be interested in: :help on mkspell and lang. As for why I found this I'm having a strange file where even on a file type that I specify to have spellcheck it doesn't work. Anyway I hope these comments help you (and anyone else) out in the future! Cheers and stay safe mate.
    – Pryftan
    Mar 24, 2022 at 10:07
  • I actually just ran into this problem with a markdown file in particular. As I commented in the question but maybe it'll be better here: I just ran into this problem and this is what happened in my case. There was a typo which resulted in a `` block not being closed which means that things past it would be in code so not spellchecked! So for anyone who runs into this problem with a markdown file check that as well. Fortunately my eyes zoom in on typos (it was not my typo).
    – Pryftan
    Jan 31, 2023 at 12:17
0

It seems that the spell files are not downloaded by vim. A possible reason is that one of your plugins (probable nerdtree) is disabling the plugin needed to download these files. The readme explains how to fix it:

However, Vim ships with a plugin that does just that. It's called netrw, and by adding the following lines to your .vimrc, you can use it to open files over the scp:, ftp:, or other protocols, while still using NERDTree for all local files. The function seamlessly makes the decision to open NERDTree or netrw, and other supported protocols can be added to the regular expression.

" Function to open the file or NERDTree or netrw.
"   Returns: 1 if either file explorer was opened; otherwise, 0.
function! s:OpenFileOrExplorer(...)
    if a:0 == 0 || a:1 == ''
        NERDTree
    elseif filereadable(a:1)
        execute 'edit '.a:1
        return 0
    elseif a:1 =~? '^\(scp\|ftp\)://' " Add other protocols as needed.
        execute 'Vexplore '.a:1
    elseif isdirectory(a:1)
        execute 'NERDTree '.a:1
    endif
    return 1
endfunction

" Auto commands to handle OS commandline arguments
autocmd StdinReadPre * let s:std_in=1
autocmd VimEnter * if argc()==1 && !exists('s:std_in') | if >SID>OpenFileOrExplorer(argv()[0]) | wincmd p | enew | wincmd p |endif | endif

" Command to call the OpenFileOrExplorer function.
command! -n=? -complete=file -bar Edit :call <SID>OpenFileOrExplorer('<args>')

" Command-mode abbreviation to replace the :edit Vim command.
cnoreabbrev e Edit
0

You might get a hint if you enter the Vim command: :set spell?

I did so and it told me my spellfile was not set.

Spellcheck had been working for me. Now, with no explanation, Vim seemed no longer to know the spellfile it had been using was still there.

I found that it does exist in the place where it is supposed to be:

._. ls ~/.vim/spell
en.utf-8.add  en.utf-8.add.spl

So I set it at the vim command line:

:set spellfile=/home/yuzer/vim/spell/en.utf-8.add

This didn't actually work because I had a typo in the spellfile path. :set spell? told me that again. So I fixed it:

:set spellfile=/home/yuzer/.vim/spell/en.utf-8.add

But bizarrely, it only highlighted unrecognized words that appeared in filepaths written in the body of the text document. It did not recognise spelling errors in ordinary prose text.

The problem was that, though I was editing a text file, my file was set with filetype=python (because I like the syntax highlihting). I fixed the problem by changing the filetype to text:

:set ft=text

Spelling now works again.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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