Shows what is missing between 2 buffers
This is a mirror of http://www.vim.org/scripts/script.php?script_id=1108 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.