Created
March 5, 2012 21:36
-
-
Save alexdresko/1981263 to your computer and use it in GitHub Desktop.
GetSublimeTextKeyBindingsFromVisualStudioKeyboardShortcuts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sub GetSublimeTextKeyBindings() | |
Dim cmd As Command | |
Dim ow As OutputWindow = DTE.Windows.Item(Constants.vsWindowKindOutput).Object | |
Dim owp As OutputWindowPane | |
Dim exists As Boolean | |
Dim i As Integer | |
Dim sArray() As String | |
Dim dict As New System.Collections.Generic.Dictionary(Of String, String)() | |
dict.Add("Edit.NextBookmark", "next_bookmark") | |
dict.Add("Edit.ToggleBookmark", "toggle_bookmark") | |
dict.Add("Edit.CommentSelection", "toggle_comment") | |
dict.Add("Edit.UncommentSelection", "toggle_comment") | |
sArray = New String() {} | |
i = 1 | |
exists = False | |
For Each owp In ow.OutputWindowPanes | |
If owp.Name = "SublimeTextKeyBindings" Then | |
exists = True | |
Exit For | |
End If | |
i = i + 1 | |
Next | |
If exists Then | |
owp = ow.OutputWindowPanes.Item(i) | |
Else | |
owp = ow.OutputWindowPanes.Add("SublimeTextKeyBindings") | |
End If | |
owp.Clear() | |
' Output 1 line per command | |
For Each cmd In DTE.Commands | |
Dim binding As Object | |
Dim shortcut As String | |
shortcut = "" | |
For Each binding In cmd.Bindings | |
Dim b As String | |
b = binding | |
If b.Contains("Text Editor::") Or b.Contains("Global::") Then | |
If shortcut = "" Or b.Contains("Text Editor::") Then | |
shortcut = b | |
End If | |
End If | |
Next | |
shortcut = shortcut.Trim().Replace("Text Editor::", "").Replace("Global::", "") | |
If Not cmd.Name.Trim().Equals("") And Not shortcut.Equals("") Then | |
Dim split As String() = shortcut.Replace(" ", "").ToLower().Split(",") | |
Dim result As String = """" + String.Join(""", """, split) + """" | |
If dict.ContainsKey(cmd.Name) Then | |
sArray.Resize(sArray, sArray.Length + 1) | |
sArray(sArray.Length - 1) = vbTab + "{ ""keys"": [" + result + "], ""command"": """ + dict(cmd.Name) + """ }" | |
End If | |
End If | |
Next | |
Array.Sort(sArray) | |
owp.OutputString(String.Join(", " + vbCrLf, sArray)) | |
End Sub |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Wow... I..uhh.. I don't know and I don't remember. :)