有没有办法告诉vim更新列出的所有语言的拼写文件,'spelllang'从vim外部获取wordlist更改?
我已经开始将wordlist文件检入git,因为我厌倦了在多台计算机上添加相同的单词.我不想将拼写文件添加到git repo,因为每次合并都会很难看,但每当我打开vim时,任何最近的更新都会被忽略,直到我从vim里面做一些重建拼写文件的事情,比如zg添加一个字到字典.
小智 11
我已经通过将*.spl添加到.gitignore文件然后在vimrc(也与GIT同步,添加:
for d in glob('~/.vim/spell/*.add', 1, 1)
if filereadable(d) && (!filereadable(d . '.spl') || getftime(d) > getftime(d . '.spl'))
exec 'mkspell! ' . fnameescape(d)
endif
endfor
Run Code Online (Sandbox Code Playgroud)
来源:https://vi.stackexchange.com/questions/5050/how-to-share-vim-spellchecking-additions-between-multiple-machines
每次在启动vim时更新.add文件时,这将导致vim重建.spl文件.
小智 0
使用字典的 git 存储库很有意义。问题在于告知vim您的字典。一个简单的解决方案是映射 vim 以使用正确的字典。例如,如果你的单词是 inmy-dictionary.txt那么你可以从 vim 运行:
:mkspell ~/.vim/spell/en_my_dict /path/to/git/repo/my-dictionary.txt
Run Code Online (Sandbox Code Playgroud)
我可能会使用类似的东西:
" Set up Dictionary for check
" This is will add your dictionary to existing list.
" To use only your dictionary use, setlocal &spelllang=en_my_dict
nmap <leader>ss :setlocal &spelllang=join(add(split(&spelllang, ','), 'en_my_dict'), ',')
" Spell Check (Redo to disable)
nmap <silent> <leader>sc :set spell!<CR>
Run Code Online (Sandbox Code Playgroud)