Can i switch the vim option when switching to insert mode?

I recently discovered a spell option thanks to this answer to code review , and I feel that this option is really useful (when editing) and really annoying (while the reading code is due to all the false positives).

I would like to somehow enable the parameter automatically when switching to insert mode:

set spell 

and automatically turn it off when switching to normal mode:

 set nospell 
+7
source share
1 answer

Adding the following commands to your .vimrc should do the trick (unless you use CTRL + C to exit into insert mode):

 autocmd InsertEnter * setlocal spell autocmd InsertLeave * setlocal nospell 

Since this is a great trick, I added these lines to my .vimrc !

if you want to get rid of the highlighted words, you can add them to the "good" list of words by hovering over them and typing zg . See :help spell for more information

+9
source

All Articles