Does VIM highlight unique words in the buffer?

When using vim to program any unique words in a file / buffer, there will most likely be a typo (ether variable name, method name, or language construct). Thus, it would be a good way to catch such typos with the possibility of highlighting any unique words in the file, without any fancy language analysis or parsing, or even need to know which programming language is used. Of course, it would be better if this happened when you typed in order to immediately see your typos. For some reason, I do not do that I am the first to come up with such an idea, so maybe someone has such a setting or have any suggestions?

+4
source share
1 answer

Creative idea.

I made some quick prototypes with this Vimscript snippet:

let stat = {} for ii in range(1, line('$')) for word in split(getline(ii), '\(\k\@!.\)\+') let stat[word] = get(stat, word, 0) + 1 endfor endfor echo sort(keys(filter(copy(stat), 'v:val == 1'))) 

By running this on $ VIM / vim73 / autoload / vimball.vim (a 23.2 kilobyte file with 737 lines), I get the following separate keywords:

 12, 1502, 2004, 2009, 2010, 299, 31, 4, 702, Allow, Apr, At, Author, AutoInstall, Constants, Copyright, Date, DechoTabOn, ENTER, Error, Functions, GetLatestVimScripts, Input, LICENSE, Listing, Load, Modelines, No, Normal, Once, Output, Own, Ph, Risk, Statement, Usage, Use, VIM, Version, Vim, Windoze, Your, about, accomplished, actions, allow, already, appear, appears, applies, apportion, assume, attempts, automatically, base, based, bash, both, bypass, c, ch, change, construct, continue, copyright, cp, cr, create, creates, cygwin, decompress, decompression, defined, did, dir, distribute, does, doesn, embedded, enc, endfor, even, events, evidence, except, existing, express, extraction, fmr, fo, force, function, getpos, give, given, grab, ie, implied, included, index, initialize, input, inputrestore, inputsave, insure, invoked, its, just, keep, keepcpo, list, listing, loop, made, messages, missing, mkvimball, named, neither, next, noacd, nofile, noma, nor, normal, noruler, noshowcmd, ok, older, on, option, options, over, patch, pick, picked, placed, present, previous, prologue, prompt, read, readable, redraw, removed, same, see, setpos, setting, settings, shell, showing, skip, specified, specify, spite, split, standard, string, strlen, sure, suspect, switch, ta, tab#, take, that, title, true, un, undefined, under, used, v31, various, warning, warranty, was, when, where, will, wrote, your, zsh 

Hm, it’s not very useful to me (it’s also not much better when comments are excluded), but maybe you can do it and improve it.

+2
source

All Articles