#vim
https://lazybear.io/posts/how-to-use-thesaurus-with-vim/
{width="90px" heigth="91px"}{.navbar-brand}
{.u-photo} Hyde{rel="author" hidden=""}
2024-02-15 00:42:01 +0000 UTC about 433 words 2 min
tags: Vim{.p-category} neovim{.p-category} thesaurus{.p-category}
\
Neovim, along with tmux, is probably the software I use the most on a daily basis. I use it for taking notes, configuring servers, coding, and writing blog posts. I cannot imagine my life without it anymore.
Occasionally, when writing blog posts or documentation, I need to find synonyms. While I could search for them online, the good news is that I can use Vim/Neovim for this purpose.
First, a little definition. What is a thesaurus?
A thesaurus is a reference work that lists words grouped by similarity of meaning, often with definitions, antonyms and usage examples.
By default, Vim/Neovim doesn't come with a thesaurus installed.
There are plugins available to add them, but that's not what we're going to do. I'll show you how to use a text file full of synonyms.
Here is a French, and an English one, that you can also find in the documentation (:h compl-thesaurus)
Those files contains lines like this:
spy operative spectator witness viewer watcher looker descry spot espy sight
spyeria Spyeria
spyglass glass
spyhole peephole hole
spying watch vigil intelligence detection catching espial spotting discovery
There is nothing particularly noteworthy about those files. It is possible to add your own words if desired.
If you use Vim:
- download or create your thesaurus files
- configure your
~/.vimrc
to use them by adding that line:
set thesaurus += ~/.vim/thesaurus/thesaurus-english.txt # or any path you want
set thesaurus += ~/.vim/thesaurus/thesaurus-french.txt # if you have more than one
That's all!
For Neovim, I have a ~/.config/nvim/lua/hyde/options.lua
with a small loop:
-- options.lua
local o = vim.opt
[...]
-- thesaurus
local thesaurusfiles = {
"~/.config/nvim/thesaurus/thesaurus-english.txt",
"~/.config/nvim/thesaurus/thesaurus-french.txt"
}
for _, path in ipairs(thesaurusfiles) do
o.thesaurus:append(path)
end
Let learn how to use once it has been configured.
When using Vim/Neovim, you can access a thesaurus completion feature by typing
Ctrl-x Ctrl-t
while in Insert mode. This will provide you with a list of
synonyms.
abbey[Ctrl-x Ctrl-t]
abbey /home/hyde/.config/nvim/thesaurus/thesaurus-english.txt
church /home/hyde/.config/nvim/thesaurus/thesaurus-english.txt
convent /home/hyde/.config/nvim/thesaurus/thesaurus-english.txt
monastery /home/hyde/.config/nvim/thesaurus/thesaurus-english.txt
The only issue arises when a completion occurs on certain words, such as 'spy'. This word is also present on different lines of the thesaurus file:
a*spy* rough gruff hoarse husky piercing raucous strident rending ripping splitting noisy
counterspy mole spy
cri*spy* crisp
descry spot e*spy* spy sight
detection espial *spy*ing spotting discovery find uncovering contracting acquiring getting
The line completion feature searches for and suggests the following lines based on the input. Therefore, the suggested synonyms may not be accurate.
I have raised an issue, and hope that it will be resolved soon.
Post 4/100 - Round 5 of the 100DaysToOffload challenge !
\
Join the discussion on the Fediverse or using webmention
Load comments
You need JavaScript to view the comments.
\
Vim's creator, Bram Moolenaar, passed away{.text-body}
Vim creator is gone. At a fairly young age. He was 62. His family announced that on the Vim announce mailing list. I have been a Vim user for at least 15 years.
Read more{.btn .btn-primary .btn-sm}
Dvorak and typing{.text-body}
I've been using a Dvorak layout for a couple of years now. I think I started around 2019, but I'm not 100% sure. I got pretty decent with it.
Read more{.btn .btn-primary .btn-sm}
{.u-url rel="me"} {.u-url rel="me"} {.u-url rel="me"} {.u-url rel="me"}
All content licensed under CC BY-NC-SA 4.0 unless otherwise stated.