简体   繁体   中英

Set spelling exception in vimrc

When editing a text in markdown, I don't want to highlight bibliography entries. This can be achieved with the following command:

:syn match CitNoSpell '\[@[^[:space:]]\+\]' contains=@NoSpell

However, if I enter this command to .vimrc , it is ignored. I assume that is because spell file is loaded after vimrc has been read, and this definition is not kept.

How should I force vim to ignore this pattern? I prefer it to stay in .vimrc, as I synchronize the file across multiple systems, but another solution would also be welcome.

As the ~/.vimrc is loaded first (before any files), the syntax of an opened file is set only later, and syntax scripts :syntax clear any existing syntax stuff, including your definition.

The right place for your customization would be the :help after-directory ; ie ~/.vim/after/syntax/markdown.vim , as this will be sourced after $VIMRUNTIME/syntax/markdown.vim .

If you insist on configuring this within your ~/.vimrc , you can try the following autocmd, which has to be put somewhere after :syntax on :

autocmd Syntax markdown syn match CitNoSpell ...

PS: For consistency, as you're tweaking the Markdown syntax, your added syntax group should also start with the syntax name, ie markdownCitNoSpell .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM