I’m announcing my plugins in order of their popularity on Package Control. #1 spot goes to zenburn, which I’m glad to see. #2 is FileDiffs. This is not surprising, because I think it offers many of the TextMate “diff” commands, but with the ST2 spin.
The commands it provides are:
-
Diff file with Clipboard
-
Diff Selections
-
Diff file with Saved
-
Diff file with File in Project…
-
Diff file with Open Tab…
If you have selected some text, “Diff file” changes to “Diff selection”. “Diff selections” is only available when there are exactly two selections in the current view. “Diff file with Open Tab” will show a picker for the open tabs (unless there are just two open, it will just pick the other tab). Diff file with File in Project uses the fuzzy finder.
The diff is calculated using python’s difflib library, using the unified_diff command. I had some headaches getting unicode to diff correctly, so bear with me if your files aren’t decoding correctly. AFAIK, it only supports UTF8. If you need to diff two files with different encodings, try using “Diff file with Open Tab”. It uses sublime text to fetch the content, so it should deal with the encoding transparently.
Next, my question about etiquette. In writing plugins, my first audience (me!) gets special consideration. I add key mappings that are intuitive to me, and add them to a Defaults (OSX).sublime-keymap file. I also create Windows and Linux versions, just for consistency. The keymap file for FileDiff looks like this:
{ "keys": "ctrl+shift+d"], "command": "file_diff_menu" }
]
When I publish these plugins, I have very mixed feelings about including these keymap files. What I like is that these files show the commands and options the package provides. What I don’t like is that hit all users will agree with my keymappings.
Is there a standard in place for including or excluding keymap files? Or what to name example files?