开发者

Automatically enabling spell checking in vimrc

开发者 https://www.devze.com 2023-04-02 06:02 出处:网络
How can I enable spell checking to be automatically enabled in the .vimrc file? Perhap开发者_运维问答s there\'s a way to define a quick shortcut that would toggle it instead.

How can I enable spell checking to be automatically enabled in the .vimrc file? Perhap开发者_运维问答s 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?


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


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

au BufRead *.txt setlocal spell


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.


:e $MYVIMRC

append a line:

setglobal spell spelllang=en_us

(or similar)

:w|source %

Profit


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消