VIM is the editor I use for programming. It is known for its power at writing code thanks to its built in features and numerous plugins, but how does it serve for blogging? Let’s investigate on how to improve its default behavior.
Spell checking is built in feature of VIM, but it is disabled by default. I’ve enabled it with:
set spell spelllang=en_us
That made VIM highlight my spelling errors. I can jump between misspelled words with
[s. With the cursor located on a misspelled word I can type
z= to get a list of possible fixes. When VIM is wrong I can tell it to accept a word with
zg (undo with
VIM supports expansion of user defined abbreviations. For instance, if you define “utl” as an abbreviation of “utility”, VIM automatically replaces “utl” with “utility” when typing. This feature can be used for auto correction. Just define:
:iabbrev veiw view
to make VIM replace each “veiw” with “view” on the fly (in insert mode). Vim-autocorrect is one of the plugins that come with a set of predefined useful abbreviations so you don’t have to provide definitions of the most common ones.
Next feature is auto completion. It is also supported by default but you may need to provide the dictionary and that was my case. Check if you have
/usr/share/dict/words. I use Slackware and Ubuntu on daily basis; Slackware happened to have the dictionary installed, but on Ubuntu it was not there. Managed to provide the dict with
sudo apt install wamerican. That tells VIM to use the dictionary file:
Now that the dictionary is set up, it can be used with
<C-x><C-k> in insert mode.
Looking for synonyms? VIM supports thesaurus, however it has to be configured. I was able to configure the built in feature but it needed a hack to handle multi word synonyms and I didn’t like that. I’ve decided to install vim-lexical plugin instead. Just as the built in feature, the plugin needs a synonyms file to work: grabbed one from Project Gutenberg. Tell vim-lexical where the file is and initialize the plugin:
let g:lexical#thesaurus = ['~/.vim/mthesaur.txt'] call lexical#init()
This plugin also handles dictionary and spell check features, I gave it a try. Here are some settings to set it up:
let g:lexical#spelllang = ['en_us'] let g:lexical#dictionary = ['/usr/share/dict/words'] " normal mode key mappings: let g:lexical#spell_key = '<leader>s' let g:lexical#thesaurus_key = '<leader>th' let g:lexical#dictionary_key = '<leader>k'
In insert mode, we can use
<C-x><C-t> for thesaurus.
There are more plugins that support the writers, I present some that I have found particularly useful.
Wordy lets you identify phrases that are overused, misused, abused, colloquial, idiomatic etc. It’s a nice lightweight tool that operates on higher level than just single words. Definitely worth checking out.
Struggling with word repetitions? Ditto is there to localize & highlight them for you.
LSP + proselint
Proselint is not a VIM plugin. It is a separate tool described as a linter of English prose. Here are some of its features:
- Avoiding archaic forms
- Avoiding needless backformations
- Avoiding redundant currency symbols
- Avoiding false plurals
- Avoiding illogical forms
- Avoiding the word suddenly
- Avoiding oxymorons
- Calling jobs by the right name
- Not comparing uncomparables
- Using dïacríticâl marks
- Linking only to existing sites
Full list here. Since the tool is a linter, it sounds like it should work with language servers. I use CoC.nvim for LSP features. Thankfully some smart guys have figured out how to make proselint work with coc.nvim & coc-diagnostic (see here). Now it works for my blog posts just like clangd does for my C++ code.
Let’s see how it works
All these solutions look promising. I’ve already benefited from including them in my VIM configuration while writing this blog post. Will do further testing and investigation in next days. Didn’t try plugins like vim-pencil or vim-abolish yet.
- Using spell checking in VIM
- Using a Thesaurus File in VIM
- VIM Spell Check
- VIM for writing
- 10 VIM plugins for writers
Comments on dev.to.