Browse files

Add 'Surround keybindings' to DefaultKeyBinding.dict.

  • Loading branch information...
1 parent 7c14d7b commit 906009e1b9a3de4b9e7bb707f5c2efb9a88c8138 @emmanuel committed Aug 22, 2012
Showing with 25 additions and 0 deletions.
  1. +25 −0 Library/KeyBindings/DefaultKeyBinding.dict
View
25 Library/KeyBindings/DefaultKeyBinding.dict
@@ -35,4 +35,29 @@
"^x" = ("insertText:", "\U238B"); // ⌃X escape
"x" = ("insertText:", "\U23CF"); // X eject
};
+
+ "^@s" = { // surround commands: two-stroke bindings starting with ⌘⌃S
+ // wrap () with spaces
+ "(" = (delete:, insertText:, "( ", yank:, insertText:, " ", moveLeft:, insertText:, " )", deleteForward:);
+ // wrap () no spaces
+ ")" = (delete:, insertText:, "( ", deleteBackward:, yank:, insertText:, " ", moveLeft:, insertText:, ")", deleteForward:);
+ // wrap [] with spaces
+ "[" = (delete:, insertText:, "[ ", yank:, insertText:, " ", moveLeft:, insertText:, " ]", deleteForward:);
+ // wrap [] no spaces
+ "]" = (delete:, insertText:, "[ ", deleteBackward:, yank:, insertText:, " ", moveLeft:, insertText:, "]", deleteForward:);
+ // wrap {} with spaces
+ "{" = (delete:, insertText:, "{ ", yank:, insertText:, " ", moveLeft:, insertText:, " }", deleteForward:);
+ // wrap {} no spaces
+ "}" = (delete:, insertText:, "{ ", deleteBackward:, yank:, insertText:, " ", moveLeft:, insertText:, "}", deleteForward:);
+ // wrap <> with spaces
+ "<" = (delete:, insertText:, "< ", yank:, insertText:, " ", moveLeft:, insertText:, " >", deleteForward:);
+ // wrap <> no spaces
+ ">" = (delete:, insertText:, "< ", deleteBackward:, yank:, insertText:, " ", moveLeft:, insertText:, ">", deleteForward:);
+ // wrap single quotes
+ "'" = (delete:, insertText:, "' ", deleteBackward:, yank:, insertText:, " ", moveLeft:, insertText:, "'", deleteForward:);
+ // wrap backticks
+ "`" = (delete:, insertText:, "` ", deleteBackward:, yank:, insertText:, " ", moveLeft:, insertText:, "`", deleteForward:);
+ // wrap double quote
+ "\"" = (delete:, insertText:, "\" ", deleteBackward:, yank:, insertText:, " ", moveLeft:, insertText:, "\"", deleteForward:);
+ };
}

0 comments on commit 906009e

Please sign in to comment.