WhatsMissing.vim : Shows what is missing (or not) between 2 buffers
script karma |
Rating 0/2,
Downloaded by 1947 |
Comments, bugs, improvements
|
Vim wiki
|
created by |
David Fishburn |
|
script type |
utility |
|
description |
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
or
- contained in both buffers
The plugin has created a menu, Plugin->WhatMissing. There are a few entries:
WhatsMissing
WhatsNotMissing
Remove Matches
These menu items are also available in visual mode. These menu items simply call the commands:
:WhatsMissing
:WhatsNotMissing
:WhatsNotMissingRemoveMatches
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:
:WMGetOption option_name
Here are the various options:
mode
- 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.
ignore_case
- 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
it.
ignore_whitespace
- Values: "0" or "1".
- If in "line" mode, you can choose to ignore leading and trailing
whitespace for the comparison.
WhatsMissing
-------------------
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:
**************
abs
absolute
action
activ
expanded
experience_estimate
explanation
explicit
express
exprtype
remainder
remote
remove
rename
reorganize
replicate
rereceive
resend
reset
value
values
varbinary
varchar
varexists
**************
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
----------
abs
absolute
action
activ
expanded
experience_estimate
explanation
explicit
express
exprtype
remainder
remote
remove
rename
reorganize
value
values
varbinary
varexists
----------
WMOptions:
mode=word ignore_case= ignore_whitespace=0
***************
Of course, the above example is for Vim syntax files, but it can be used for anything.
WhatsNotMissing
-----------------------
Is nearly identical to WhatsMissing, except it will tell you which words are in both files. I use this in conjunction with WhatsNotMissingRemoveMatches.
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
mysyntax.vim file.
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.
|
|
install details |
The zip file contains the necessary path structure.
On *nix, unzip into:
$HOME/.vim/
On Windows unzip into:
vim/vimfiles/
Files:
plugin/whatsmissing.vim
autoload/whatsmissing.vim
doc/whatsmissing.txt
To update the Vim Help, run:
:helptags $HOME/.vim/doc (Unix)
:helptags $VIM/vimfiles/doc (Windows)
|
|
script versions (upload new version)
Click on the package to download.
whatsmissing_5.zip |
5.0 |
2012-10-18 |
7.0 |
David Fishburn |
New Features:
Added filename completion to WhatsMissing and WhatsNotMissing
Added new command WhatsNotMissingRemoveMatches, see description and :h WhatsMissing.txt for more details.
|
whatmissing_4.zip |
4.0 |
2012-10-13 |
7.0 |
David Fishburn |
- 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
|
WhatsMissing.vim |
3.0 |
2012-01-23 |
6.0 |
David Fishburn |
There was a logic error when prompting the user for the options. Ignore case value was reversed. |
WhatsMissing.zip |
1.0 |
2004-10-17 |
6.0 |
David Fishburn |
Documentation and GetLastestVimScripts support |
ip used for rating: 18.191.203.35
|