Matty
Matty

Reputation: 34443

Automatically enabling spell checking in vimrc

How can I enable spell checking to be automatically enabled in the .vimrc file? Perhaps there's a way to define a quick shortcut that would toggle it instead.

Better yet, is possible to enable it for certain file extensions only?

Upvotes: 19

Views: 9976

Answers (5)

Sparhawk
Sparhawk

Reputation: 1677

This is similar to Xavier T.'s answer but will spell-check the local buffer only, specify the language or region, and set the toggle to F5. Put the following in ~/.vimrc

:map <F5> :setlocal spell! spelllang=en_us<CR>

You can also use en_au, en_ca, en_gb, etc.

Upvotes: 2

evaryont
evaryont

Reputation: 419

For only certain file extensions, you can use the autocommands in Vim:

au BufRead *.txt setlocal spell

Upvotes: 22

Xavier T.
Xavier T.

Reputation: 42218

To quickly toggle spelling on and off, you can use the following mapping:

nmap <silent> <leader>s :set spell!<CR>

Spell check tends to slow down the loading of big files.

Upvotes: 6

sehe
sehe

Reputation: 392931

:e $MYVIMRC

append a line:

setglobal spell spelllang=en_us

(or similar)

:w|source %

Profit

Upvotes: 2

Alex
Alex

Reputation: 15333

You should be able to just put set spell in your .vimrc file.

Upvotes: 28

Related Questions