brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: :setlocal spell turns on Vim's spell checker, and z= suggests the fix

Vim
~/tips/tip-vim-spell-spelllang-z-equals

:setlocal spell spelllang=en_us

Highlights misspelled words in Vim and lets you pick a correction from a list.

Plenty of people install a plugin or paste text into a browser to check spelling, while Vim has had a spell checker built in all along. One option switches it on, and every word Vim doesn’t know gets highlighted. I like that it needs nothing extra.

Here’s the command, straight from the quick start in the Vim help:

:setlocal spell spelllang=en_us

I’d use :setlocal rather than :set, so only the buffer you’re writing in gets the highlighting and your code in the other split stays quiet. spelllang takes a comma-separated list, so living in Leiden I’d go for spelllang=en_us,nl and have both English and Dutch accepted in the same file.

Then you need a few keys. ]s jumps to the next misspelled word and [s to the previous one. On a flagged word, z= shows a numbered list of suggestions sorted by how close they are; type the number and press Enter. zg adds the word under the cursor to your own word list (good for names and jargon like Jellyfin), and zw marks a word as wrong.

An example: you finish a README, type :setlocal spell spelllang=en_us, then hit ]s and z= until the file is clean. :setlocal nospell turns it off again.

The catch: a language only works when its spell file is on your system, and depending on how your Vim was packaged that may not be the case for Dutch. When you ask for nl and the file is missing, the spellfile.vim plugin offers to download it, and it needs a writable directory in your runtimepath to save it. Also keep your expectations low on grammar: the help says plainly that Vim only checks spelling.

Further reading: Vim help: spell.txt, Vim help: 'spelllang'

Going deeper: Guide: advanced tmux, a config that grows with you, formats, layouts and more

More Vim tips :%s/<Ctrl-r><Ctrl-w>/newname/g /oldname find . -name "*.conf" | vim – vim --clean file.txt :set textwidth=72 All Vim tips (45) All topics

Link