Is it possible to toggle a vim option when switching to insert mode?
I recently discovered the spell option thanks to this answer on Code Review, and I feel that the option is both really useful (while editing) and really annoying (while reading code, because of all the false positives).
I would like to somehow enable the option automatically when switching to insert mode:
set s开发者_开发知识库pell
and disable it automatically when switching back to normal mode:
set nospell
Adding the following commands in your .vimrc
should do the trick (as long as your not using CTRL+C to leave insert mode) :
autocmd InsertEnter * setlocal spell
autocmd InsertLeave * setlocal nospell
Since this is a great trick, I have added these lines to my .vimrc
!
if you want to get rid of words being highlighted, you can add them to the "good" word list by putting the cursor over them and type zg
. See :help spell
for more information
精彩评论