My favourite lightweight editor on Linux is Leafpad. Though I am more comfortable with vim, I use Leafpad for drafting articles like this one. An option Leafpad lacks is spell checking and I was looking for another alternative to do that. However, most of them were bulky or written in languages like Python making them damn slow.
Finally I ended up enabling spell check by default in vim. To do that, I added the following in ~/.vimrc:
However, I prefer to use UK English spellings. The system default is US English. To use the UK option I ad to add the following:
setlocal spell spelllang=en_gb
Note that this also enables spellcheck so you do not need to add the earlier switch. To urn it off, type in the following while in command mode of vim:
To check only comments and not actual code, add the following line:
The syntax description files already know what to check and what not.
To add a word to the dictionary, place the cursor on the word and press
<zg> in command-mode.
Whitespace removal on save
To remove all trailing whitespace characters from a file when you save it, add the following auto-command to ~/.vimrc:
autocmd BufWritePre * :%s/\s\+$//e
To specify a single file type:
autocmd BufWritePre *.c :%s/\s\+$//e
To specify certain file types:
autocmd FileType c,cpp,java,php autocmd BufWritePre <buffer> :%s/\s\+$//e