WhatsMissing.vim : Shows what is missing (or not) between 2 buffers
| script karma
Downloaded by 1116
Comments, bugs, improvements
script versions (upload new version)
|This plugin contains functions/commands that will cycle through one
buffer (the source) and compare the its contents against the contents of
another buffer (the target).
NOTE: This is not a poor man's 'diff', since the source and target must be
similar in appearance. See example below for a better understanding.
Depending on the options specified and command chosen, it will open a split
window (the result) and display either the entries that are:
- missing from the target buffer
- contained in both buffers
The plugin has created a menu, Plugin->WhatMissing. There are a few entries:
These menu items are also available in visual mode. These menu items simply call the commands:
The behavior of whatsmissing.vim are governed by several options. Options can be specified using the WMSetOption command. As mentioned above, the <Tab> button can be used for both option name and option value completion.
You can check the value of a specific option by:
Here are the various options:
- Values: "word" or "line".
- WhatsMissing will move through the source buffer one |word| at a
time, and checks this value against the target buffer. It will
also automatically escape the following characters:
If the "line" mode is chosen the comparison between the source
and target buffer is performed a line at a time.
- Values: "0" or "1".
- The "default" for WhatsMissing is to use the |'ignorecase'| option
of the target buffer. Otherwise the user is allowed to override
- Values: "0" or "1".
- If in "line" mode, you can choose to ignore leading and trailing
whitespace for the comparison.
Consider the case where you are maintaining a Vim syntax file. It has entries like this:
syn keyword sqlFunction count sum avg min max debug_eng isnull
syn keyword sqlFunction greater lesser argn string ymd todate
syn keyword sqlFunction sp_addalias
syn keyword sqlFunction sp_addauditrecord
syn keyword sqlKeyword replicate rereceive resend reset
syn keyword sqlKeyword resolve resource respect
syn keyword sqlKeyword restrict result retain
syn keyword sqlStatement allocate alter backup begin call case
syn keyword sqlStatement checkpoint clear close commit configure connect
syn keyword sqlStatement create deallocate declare delete describe
syn keyword sqlType char long varchar text
syn keyword sqlType bigint decimal double float int integer numeric
In order to create the syntax file in the first place you had to find the above words from somewhere. In this case, I simply used grep against the source code to find various API method names, keywords, functions and so on.
So in the end after running grep repeatedly and massaging the output, I end up with a file like this:
At this point you want to update your Vim syntax file to include all the new method names, keywords, functions and so on that are missing from the existing syntax file.
You cannot run Diff against this, since the lines are completely different, you need to compare the words.
After running :WhatsMissing, you end up with a split buffer showing (in this case), only the words missing. This reduces the work required to determine which syntax elements to add to your file.
(19 of 24) items missing from: syntax.vim
mode=word ignore_case= ignore_whitespace=0
Of course, the above example is for Vim syntax files, but it can be used for anything.
Is nearly identical to WhatsMissing, except it will tell you which words are in both files. I use this in conjunction with WhatsNotMissingRemoveMatches.
When I create my syntax files, I run a process against source files
to generate a list of syntax items. I then compare this file to my
mysyntax.vim file using the WhatsMissing command. Any items missing
I added to the mysyntax.vim file.
There can be times though, that I generate my syntax list file, but
since this can be an less than exact science, I already have another
file with a list of words that I have already analyzed and determined
they are not valid syntax items. So when the target software releases
a new version, I have to go through this process a second time. So,
the steps become:
1. I generate a list of syntax items.
2. Using WhatsNotMissing, I check this new list against another
list of items I already know should not be included in the
3. WhatsNotMissingRemoveMatches will loop through the matches
and remove them from step 1.
4. Now I run WhatsMissing from the file in step 1 against
the mysyntax.vim file.
5. Now the list of words which are missing, I go through each one
and either add them word to mysyntax.vim or I add it to
file (from step 2) which is a list of exclusions.
6. The list of exclusions is now ready for the next time the software
release happens, I do not have to redo that work.
|The zip file contains the necessary path structure.
On *nix, unzip into:
On Windows unzip into:
To update the Vim Help, run:
:helptags $HOME/.vim/doc (Unix)
:helptags $VIM/vimfiles/doc (Windows)
Click on the package to download.
ip used for rating: 188.8.131.52
Added filename completion to WhatsMissing and WhatsNotMissing
Added new command WhatsNotMissingRemoveMatches, see description and :h WhatsMissing.txt for more details.
||- Added a number of new or missing Vim Events (to be ignored)
- Converted to an autoload plugin (for faster Vim loading)
- Correctly handled the cpo for 'a' and 'A'
- Added a few more examples are more explicity defined which is the source and target files from the WhatsMissing command line
||There was a logic error when prompting the user for the options. Ignore case value was reversed.
||Documentation and GetLastestVimScripts support