I use Vim's spellchecking feature. Given that I work with many technical terms and LaTeX commands, I tend to add many them to my personal dictionary in ~/.vim/spell/en.utf-8.add.

I would like to share this file across multiple machines, so that when I add a word to the file on one machine, it is also added on other machines, and I don't need to add it once on each machine. I tried versioning ~/.vim/spell/en.utf-8.add in git, but this does not seem to work: vim does not pick up the new terms. I suspect that Vim also needs the file en.utf-8.add.spl to be edited somehow, but as this file is binary, versioning it will probably lead to conflicts.

Does anyone here have a satisfactory solution to have vim spellcheck dictionary additions as part of their config, and synchronizing them between all of their machines?

3 Answers 3


Vim uses the spl file to do the checks, and the spl file is generated from the add file. We can speculate on whether the spl file is portable across different machines and Vim versions, but it's easier (and safer) to re-generate it as needed. Now, the spl file is re-generated automatically when you add words to your local dictionary from within Vim, but you must run mkspell to re-generate it if you edit the add file directly.

With that in mind, you can do something like this: synchronize the add file by whatever means (with git, rsync, NFS, or whatever), and add these commands to your vimrc on all machines:

for d in glob('~/.vim/spell/*.add', 1, 1)
    if filereadable(d) && (!filereadable(d . '.spl') || getftime(d) > getftime(d . '.spl'))
        exec 'mkspell! ' . fnameescape(d)

This will re-generate the spl file at Vim startup whenever the corresponding add file is newer than it.

  • 3
    Brilliant, thanks! I added silent before exec so I don't get spammed at startup by the progress info of the command (and don't get "Press ENTER or type command to continue").
    – a3nm
    Oct 9, 2015 at 15:20
  • 2
    @a3nm That's a matter of preference. As an senior sysadmin explained to me many years ago, being spammed with "ok" notifications is a sign things work fine. :) Oct 9, 2015 at 18:48
  • 1
    By the way, if you are also using this setup, you probably want to automate the handling of git conflicts. I explained how to do that here: a3nm.net/blog/git_auto_conflicts.html
    – a3nm
    Mar 26, 2017 at 22:16
  • 1
    @Cbhihe: You've completely missed the point. glob() is a builtin Vim function that (as the name suggests) performs the equivalent of Bash pathname globbing. That is, glob() accepts a glob expression and returns a list or string of all pathnames matching that expression on the local filesystem. Glob expressions are like regular expressions, only simpler and less powerful. Type :h glob within Vim for gruesome details. Apr 11, 2020 at 3:34

I've created a Vim plugin for this. It finds the path to the spell folders automatically and then calls mkspell on any word lists it finds at startup to regenerate the spell files. It also creates .gitignore and .gitattributes files in the spell directories to exclude binary spell files and to use Git's union merge driver to avoid conflicts when merging spell files from two different machines. Thanks to Sato Katsura for the mkspell example.



I sync my .vim folder to my machines using Dropbox. Whenever I've made a change to my configuration, I'll throw it back onto Dropbox and pull it down on my other machines.

I have the commands set in my .bashrc file so I can save some typing. My Vim install isn't too complex, so it's pretty quick to sync when I make a change. Not sure how it'd handle an exceptionally large .vim folder.

  • 4
    Thanks for this suggestion! However, Dropbox is proprietary software, so it don't want to be using it. (It forces me to worry a lot more about its security, and it doesn't offer confidentiality guarantees of what I store in it.)
    – a3nm
    Mar 26, 2017 at 22:18
  • 2
    Avoid "dropbox". Use git versioning instead.
    – Cbhihe
    Mar 8, 2019 at 10:17

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.