:speak_no_evil: Stop repeating yourself
Ditto is a Vim plugin that highlights overused words.
You can check the most frequent words in each sentence, paragraph or file, cycle through them, choose which words to ignore and more.
Install Ditto using your favorite plugin manager or copy each file to its corresponding directory under
Add this to your
" Use autocmds to check your text automatically and keep the highlighting " up to date (easier): au FileType markdown,text,tex DittoOn " Turn on Ditto's autocmds nmap di ToggleDitto " Turn Ditto on and off
" If you don't want the autocmds, you can also use an operator to check " specific parts of your text: " vmap d Ditto " Call Ditto on visual selection " nmap d Ditto " Call Ditto on operator movement
nmap =d DittoNext " Jump to the next word nmap -d DittoPrev " Jump to the previous word nmap +d DittoGood " Ignore the word under the cursor nmap _d DittoBad " Stop ignoring the word under the cursor nmap ]d DittoMore " Show the next matches nmap [d DittoLess " Show the previous matches
(Chose the filetypes and mappings you prefer. These are only suggestions.)
Stop procrastinating and write (God knows I should).
:Dittois the command that actually does all the hard work. It highlights the most frequent word in the current file or in the current visual selection. Most other commands are just wrappers that run
:Dittoon specific parts of your file and keep it up to date.
:NoDitto, you guessed it, takes the highlighting away.
These three commands run
:Dittoon each sentence, each paragraph or on your whole file, respectively.
If you just go ahead and call one of the commands above, as soon as you make some changes in your file you'll notice that the highlighting doesn't keep up. That's where
:DittoOncomes in: besides highlighting the most frequent words, it'll add
autocmds to keep the highlighting up to date and highlight new words as soon as you type them.
:DittoOnwill update the highlighting every time you insert a or add/remove a line from your file. If you don't like that, you can also run
:DittoUpdatefrom your own
au CursorHold,CursorHoldI * DittoUpdate
So there in the example config where it says
au FileType markdown,text,tex DittoOn, what it does is run
texfiles. Whenever you edit one of those files, Ditto will automatically highlight overused words in each paragraph (the default scope can be changed with
:DittoOnis automatically disabled for readonly files, so you can call it for every text file, like in the example, and Vim's help files won't get all highlighted. If you're editing a readonly file and you still want to turn on Ditto's
autocmds, you can use
:DittoOn!, with the exclamation mark.
:DittoOff, you guessed it again, it removes the highlighting and the
g:ditto_modevariable to decide whether to highlight overused words in each sentence, paragraph or file. Whatever you set that variable to, you can also use these commands to turn Ditto on in a different mode in the current buffer.
Last but not least,
:DittoOnwhen Ditto's off and
:DittoOffwhen it's on. :sweat_smile:
Call Ditto for the current selection (in visual mode) or operator movement (in normal mode).
Map a couple of keys to these plugs and you will be able to jump to the next and previous highlighted words as if they were spelling mistakes or search results.
If you run DittoOn on a big file, soon you will find a few words that you think it's ok to repeat.
Use these plugs to ignore or stop ignoring the word under the cursor.
By default, your good words are added to the first readable directory in your
When you run any of the Ditto commands you'll see the words you use the most. Use
DittoMoreto show the second word you use the most, and then the third, fourth and so on. And then, of course, use
DittoLessto go back.
When two words are used equally as often, Ditto will highlight the longest one. If they're the same length it'll just pick one. So it's a good idea to use
DittoLessand see what the other words are.
These are the same as the eponymous commands.
Words shorter than this will never be highlighted.
Words repeated fewer times than this in each scope won't be highlighted.
This is a list of the highlight groups Ditto will use. It'll highlight as many different words per scope as there are strings in this list. So if there are 5 highlight groups in this variable, Ditto will highlight the 5 most used words in each sentence, paragraph or file.
Use this variable to set the scope used by
:DittoOn. The current options are:
let g:ditto_mode = "sentence" let g:ditto_mode = "paragraph" let g:ditto_mode = "file"
The name of the file Ditto should use to save its ignored words.
The directory where Ditto should save
g:ditto_file. It can be a comma separated list.
&l:runtimepath . "/Ditto"
You may also be interested in my other plugins:
Also I'm very susceptible to compliments. Just saying.
And that's it!
Here's a song for you, replace "Lido" with "Ditto" in your head: