有沒有什麼方法可以告訴vim更新'spelllang'
中列出的所有語言的拼寫文件,以便從vim外部獲取單詞表更改?有沒有一種快速的方法來重建拼音文件名單?
我已經開始檢查wordit文件到git中,因爲我厭倦了在多臺計算機上添加相同的單詞。我不想將拼寫文件添加到git repo,因爲每次合併都會變得很難看,但是每當我打開vim時,任何近期更新都會被忽略,直到我從vim內部重建拼寫文件(例如zg
)在詞典中添加一個詞。
有沒有什麼方法可以告訴vim更新'spelllang'
中列出的所有語言的拼寫文件,以便從vim外部獲取單詞表更改?有沒有一種快速的方法來重建拼音文件名單?
我已經開始檢查wordit文件到git中,因爲我厭倦了在多臺計算機上添加相同的單詞。我不想將拼寫文件添加到git repo,因爲每次合併都會變得很難看,但是每當我打開vim時,任何近期更新都會被忽略,直到我從vim內部重建拼寫文件(例如zg
)在詞典中添加一個詞。
使用字典的git倉庫很有意義。問題是通知vim
您的字典。一個簡單的解決方案是將vim映射爲使用正確的字典。舉例來說,如果你的話是在my-dictionary.txt
,那麼你可以從VIM運行:
:mkspell ~/.vim/spell/en_my_dict /path/to/git/repo/my-dictionary.txt
我可能會使用類似:
" 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>
您可以創建git的污跡/清潔過濾器和結賬後鉤致電:mkspell
。
$ mkdir -p ~/.vim/spell
$ cd ~/.vim/spell
$ git init
$ echo '*.spl' > .gitignore
$ touch words.utf-8.add
$ git add . && git commit -m 'init'
$ echo '*.add filter=spellfile' > .git/info/attributes
$ git config filter.spellfile.smudge cat
$ git config filter.spellfile.clean 'sort -u'
$ cd .git/hooks/
$ vim mkspell
#!/bin/sh
SPELL_FILE="`git rev-parse --show-toplevel`/words.utf-8.add" \
vim -i NONE -u NORC -U NONE -V1 -nNesc '
execute ":mkspell! " . fnameescape($SPELL_FILE) | echo "" | qall!
'
$ chmod +x ./mkspell
$ ln -s ./mkspell post-checkout
然後加入spellfile
設置成你的~/.vimrc
set spellfile=~/.vim/spell/words.utf-8.add
我已通過添加* .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
這將導致VIM每個Vim啓動時。新增文件已被更新時間重建.spl文件。
如果你只有一個單一的拼寫文件,只是把這個在您的.vimrc
:
exec 'silent mkspell! ' . &spellfile . '.spl'
我已經建立了我想要的方式拼寫文件(它在我的vimrc配置爲使用對應於spelllang 〜/ .vim/spell /中的單詞表,符號鏈接到git工作目錄中的文件)。問題在於,只要該文件從vim外部更改,vim就會繼續使用stale .spl文件而不是新的wordlist。 – 2014-12-03 01:39:47