Welcome to my site. Please CLICK HERE to give your opinions regarding this new look of "PCTipsbyAnu". Thanks for visiting.

Friday, October 15, 2010

Browse » Home » , , , , » LINUX : How to use/configure VIM for automatic spell checking?

LINUX : How to use/configure VIM for automatic spell checking?


Vim is a fantastic editor, with alot of tricks up its sleeve. It makes a great programmer’s text editor, a greatquick text file editor, and works wonders in conjunction with certain mailclients like Mutt.
One thing that may be lesser knownabout Vim is that it has built-in spelling support, which can make using it towrite email and documentation even more useful. No more need to hope yourspelling is correct, or double-checking it later with something like ispell oranother text editor.












To enable spelling support, whichwas introduced in Vim 7, use the following command in normal mode:
:setspell spelllang=en_us
Change the local code to whateverlanguage you happen to be writing in. The above is for American English; use“en_ca” for Canadian English, “en_gb” for English in Great Britain, etc.

Once spelling is activated, spellingmistakes and other inconsistencies will be color highlighted when typing ininsert mode; in gVim this will result in squiggly underlines and in Vim itself,will result in highlighted words. This largely depends on your color scheme,but typically misspelled words will be highlighted red, with otherinconsistencies such as improper capitalization being highlighted blue or cyan.


If you are working on code, you mayget tired of seeing all the highlighted misspelled “words” (i.e. function orvariable names), and you can disable spellchecking by using:
:setnospell
Vim offers some command shortcuts tonavigate to misspelled or incorrect words. The [s and ]s keyboardcommands will move you to the previous or next misspelled word, respectively. 

To see a suggested list of words in order to correct the spelling, use z=in command mode to get the suggested list of replacement words, for example:
Change"documnt" to:
 1"document"
 2 "documents"
 3 "docent"
...
Typenumber and <Enter> or click with mouse (empty cancels):

If you are like me and use Mutt foremail, with Vim as the editor, you may want spelling enabled by default only ifyou are composing an email. 
You can do something like the following if autocmdsupport was compiled into Vim, which it should be for most. 

(Some distributionsprovide a minimal Vim and an enhanced Vim; you’ll want the enhanced Vim forthis).
"Only do this part when compiled with support for autocommands.
ifhas("autocmd")
   " disable autoindent, make the background dark, change the colorscheme to
   " suit the dark background, make sure our textwidth is 72 characters and
   " disable line numbering for email
   autocmd FileType mail set noautoindent |
       \ set nosmartindent |
       \ set background=dark |
       \ colorscheme evening |
       \ set textwidth=72 |
       \ set nonumber |
       \ set spell spelllang=en_ca
endif" has("autocmd")
The above has a few more bits thatare nice when using Vim to write email, but the primary point of interest ismatching the autocmd FileType to “mail” and then setting the spell optionaccordingly. 
This will enable spelling only when the FileType is “mail”;otherwise spelling is off by default.

Because Vim and gVim make such nicetext editors, having the ability to set spelling support within them makes themthat much better. And being able to customize exactly when it is enabled, andwhen it is disabled by default, really helps to avoid remembering (orforgetting) to set it on your own.

CODE:
DOWNLOAD (Password : QQ)

  
You can leave a response, or trackback from your own site.

About 'Anu': My name is 'Anu' also Known as 'ANU 007 TIGER' .I'm administrator of 'PC Tips by Anu' blog .This blog was opened for sharing contents about hacking n cracking.
Thanks YAHOO OR GMAIL

0 comments:

Post a Comment

 
Back to Top