From 60aa2b4b8f4c07bab097e272ff9640cb5f8af73f Mon Sep 17 00:00:00 2001 From: Brett Terpstra Date: Tue, 8 May 2012 06:54:56 -0500 Subject: Added 2 new commands --- DefaultKeyBinding.dict | 17 +- document_keybindings.rb | 4 +- readme.md | 643 ++++++++++++++++++++++++------------------------ 3 files changed, 342 insertions(+), 322 deletions(-) diff --git a/DefaultKeyBinding.dict b/DefaultKeyBinding.dict index e04150b..978e9ca 100644 --- a/DefaultKeyBinding.dict +++ b/DefaultKeyBinding.dict @@ -24,6 +24,8 @@ "~S" = (moveToBeginningOfParagraph:, moveToEndOfParagraphAndModifySelection:, moveRightAndModifySelection:); // select from beginning of paragrah to last character "~s" = (moveToBeginningOfParagraph:, moveToEndOfParagraphAndModifySelection:); + // select paragraph excluding leading/trailing whitespace (same as ^$@\UF701) + "^~S" = (moveToEndOfParagraph:, insertText:, " ", selectWord:, moveBackward:, moveToBeginningOfParagraphAndModifySelection:, moveWordForwardAndModifySelection:, moveWordBackwardAndModifySelection:); // delete line/paragraph "~d" = (selectParagraph:, delete:, moveToBeginningOfParagraph:); // copy paragraph @@ -56,7 +58,7 @@ // indent line "^@l" = (setMark:, moveToBeginningOfParagraph:, insertText:, "\t", swapWithMark:, moveRight:); // outdent line (one tab or char) - "^@h" = (setMark:, moveToBeginningOfParagraph:, moveRight:, deleteBackward:, swapWithMark:, moveLeft:); + "^@h" = (setMark:, moveToBeginningOfParagraph:, moveWordRight:, moveWordLeft:, deleteBackward:, swapWithMark:, moveLeft:); // > same commands but with arrow keys // move line up @@ -66,12 +68,17 @@ // indent line "^@\UF703" = (setMark:, moveToBeginningOfParagraph:, insertText:, "\t", swapWithMark:, moveRight:); // outdent line (one tab or char) - "^@\UF702" = (setMark:, moveToBeginningOfParagraph:, moveRight:, deleteBackward:, swapWithMark:, moveLeft:); + "^@\UF702" = (setMark:, moveToBeginningOfParagraph:, moveWordRight:, moveWordLeft:, deleteBackward:, swapWithMark:, moveLeft:); // > Control-shift-command-left arrow // Full outdent - Deletes all leading space of line/paragraph (updated) "^$@\UF702" = (setMark:, moveToBeginningOfParagraph:, insertText:, " ", moveLeft:, selectWord:, delete:, swapWithMark:); - + // Delete trailing space + "^$@\UF703" = (setMark:,moveToEndOfParagraph:, insertText:, " ", selectWord:, deleteBackward:, swapWithMark:); + // Delete leading and trailing whitespace for paragraph + "^@$\UF700" = (setMark:, moveToEndOfParagraph:, insertText:, " ", selectWord:, deleteBackward:, moveToBeginningOfParagraph:, insertText:, " ", moveLeft:, selectWord:, delete:, swapWithMark:); + // Select paragraph without leading or trailing whitespace (same as "^~s") + "^@$\UF701" = (moveToEndOfParagraph:, insertText:, " ", selectWord:, moveBackward:, moveToBeginningOfParagraphAndModifySelection:, moveWordForwardAndModifySelection:, moveWordBackwardAndModifySelection:); // modify selection up by paragraph (Command Option Shift Up) "@~$\Uf700" = (selectParagraph:, moveParagraphBackwardAndModifySelection:); // modify selection down by paragraph (Command Option Shift Down) @@ -115,9 +122,9 @@ "^@c" = { // Commenting commands // comment with "//" - "/" = (setMark:, moveToBeginningOfParagraph:, insertText:, "// ", swapWithMark:, moveRight:, moveRight:, moveRight:); + "/" = (moveToBeginningOfParagraph:, insertText:, "// ", moveToEndOfParagraph:, moveForward:); // comment with "#" - "\\" = (setMark:, moveToBeginningOfParagraph:, insertText:, "# ", swapWithMark:, moveRight:, moveRight:); + "\\" = (moveToBeginningOfParagraph:, insertText:, "# ", moveToEndOfParagraph:, moveForward:); // HTML commenting "!" = (setMark:, swapWithMark:, delete:, insertText:, "", swapWithMark:, moveRight:, moveRight:, moveRight:, moveRight:, moveRight:); // Css Commenting diff --git a/document_keybindings.rb b/document_keybindings.rb index 13dbe2d..b14dc26 100755 --- a/document_keybindings.rb +++ b/document_keybindings.rb @@ -68,9 +68,9 @@ end def translate_command(str) str = str.gsub(/~/,'⌥').gsub(/@/,'⌘').gsub(/\$/,'⇧') - str = str.gsub('\Uf700','↑').gsub('\Uf701','↓').gsub('\UF703','→').gsub('\UF702','←') + str = str.gsub('\UF700','↑').gsub('\UF701','↓').gsub('\UF703','→').gsub('\UF702','←') str = str.gsub('\U0009','⇥').gsub('\U000D','↩').gsub('\U001B','⎋').gsub('\U000A','␍') - str = str.gsub('\Uf728','⌦').gsub('\177','⌫') + str = str.gsub('\UF728','⌦').gsub('\177','⌫') str = str.gsub(/([\[\]|])/,"\\\1") str = str.gsub(/([A-Z])/,'⇧\\1').downcase str diff --git a/readme.md b/readme.md index 77e1d7f..b01bb64 100644 --- a/readme.md +++ b/readme.md @@ -10,12 +10,10 @@ See Lri's [gists][lrigists] and [website][lriweb] for more coding madness. Installation: Copy the DefaultKeyBindings.dict file to the `~/Library/KeyBindings/` directory (create `KeyBindings` if it doesn't already exist). Any open applications will need to be re-started before the key bindings will take effect -- or log out and log back in. -Documentation (last updated 04/23/2012.) +Documentation (last updated 05/08/2012.) *Grouped items begin with the groups shortcut (if exists), followed by a subgroup (if exists) followed by the keys specified.* - - @@ -25,242 +23,258 @@ Any open applications will need to be re-started before the key bindings will ta - + - - + + - - + + + + + + + + + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + + + + + + + + +
General Commands
General CommandsGeneral Commands
KeyFunctionKeyFunction
^yreplace yank: command with yankAndSelect for use with the kill ring ( defaults write -g NSTextKillRingSize -string 6)^yreplace yank: command with yankAndSelect for use with the kill ring ( defaults write -g NSTextKillRingSize -string 6)
^⇧uuppercase word
^⌥ulowercase word
^⇧uuppercase word^⇧ttitlecase word
^⌥ulowercase word^⌥⇧uuppercase current paragraph
^⇧ttitlecase word^⌥ttitlecase paragraph
^⌥⇧uuppercase current paragraph^wdelete word before cursor
^⌥ttitlecase paragraph⌥wselect word
^wdelete word before cursor⌥⇧sselect entire line/paragraph
⌥wselect word⌥sselect from beginning of paragrah to last character
⌥⇧sselect entire line/paragraph^⌥⇧sselect paragraph excluding leading/trailing whitespace (same as ^$@\UF701)
⌥sselect from beginning of paragrah to last character⌥ddelete line/paragraph
⌥ddelete line/paragraph⌥ycopy paragraph
⌥ycopy paragraph⌥xcut paragraph
⌥xcut paragraph⌥ppaste paragraph below
⌥ppaste paragraph below⌥⇧ppaste paragraph above
⌥⇧ppaste paragraph above^⇧aselect to beginning of paragraph and copy
^⇧aselect to beginning of paragraph and copy^⇧eselect to end of paragraph and copy
^⇧eselect to end of paragraph and copy⌥qcut to beginning of paragraph
⌥qcut to beginning of paragraph⌥kcut to end of paragraph
⌥kcut to end of paragraph⌥oblank line after current
⌥oblank line after current⌥⇧oblank line before current
⌥⇧oblank line before current^⌘kmove line up
^⌘kmove line up^⌘jmove line down
^⌘jmove line down^⌘lindent line
^⌘lindent line^⌘houtdent line (one tab or char)
^⌘houtdent line (one tab or char)^⌘↑move line up ( same commands but with arrow keys)
^⌘↑move line up ( same commands but with arrow keys)^⌘↓move line down
^⌘↓move line down^⌘→indent line
^⌘→indent line^⌘←outdent line (one tab or char)
^⌘←outdent line (one tab or char)^⇧⌘←Full outdent - Deletes all leading space of line/paragraph (updated) ( Control-shift-command-left arrow)
^⇧⌘←Full outdent - Deletes all leading space of line/paragraph (updated) ( Control-shift-command-left arrow)^⇧⌘→Delete trailing space
⌘⌥⇧↑modify selection up by paragraph (Command Option Shift Up)^⌘⇧↑Delete leading and trailing whitespace for paragraph
⌘⌥⇧↓modify selection down by paragraph (Command Option Shift Down)^⌘⇧↓Select paragraph without leading or trailing whitespace (same as “^~s”)
^⌥⇧←modify selection left by word⌘⌥⇧↑modify selection up by paragraph (Command Option Shift Up)
^⌥⇧→modify selection right by word⌘⌥⇧↓modify selection down by paragraph (Command Option Shift Down)
⌘⌥^←Move to first Alphanumeric character of line (new)^⌥⇧←modify selection left by word
⌘⌥←Move to first non-whitespace character of line (new)^⌥⇧→modify selection right by word
⌘⌥⇧←Select to first character of line with leading space (new)⌘⌥^←Move to first Alphanumeric character of line (new)
⌥⌘→Move to last non-whitespace character of paragraph (new)⌘⌥←Move to first non-whitespace character of line (new)
^⌥→Move to end of paragraph and delete trailing whitespace (new)⌘⌥⇧←Select to first character of line with leading space (new)
⌘↩TextMate Command-Return (Command Enter)⌥⌘→Move to last non-whitespace character of paragraph (new)
⌘⇧↩Insert blank line above paragraph (Command Shift Enter)^⌥→Move to end of paragraph and delete trailing whitespace (new)
⌥_hyphenate next space and move to next word ( this will kill non alphanumeric symbols and punctuation, use only on words)⌘↩TextMate Command-Return (Command Enter)
⌥1bookmark⌘⇧↩Insert blank line above paragraph (Command Shift Enter)
⌥2jump to bookmark⌥_hyphenate next space and move to next word ( this will kill non alphanumeric symbols and punctuation, use only on words)
⌥⌘↩Continue a list item with indentation and include the same delimiter ( Command Option Enter)⌥1bookmark
⇧⇥remove one tab (or character) from start of line (outdent) ( Shift Tab)⌥2jump to bookmark
⌘⌥bbold selection (Markdown)⌥⌘↩Continue a list item with indentation and include the same delimiter ( Command Option Enter)
⌘⌥iitalicize selection (Markdown)⇧⇥remove one tab (or character) from start of line (outdent) ( Shift Tab)
⌘⌥=increase markdown header level⌘⌥bbold selection (Markdown)
⌘⌥-decrease markdown header level⌘⌥iitalicize selection (Markdown)
^⌥↩Add hard break for current line and insert newline below (new)⌘⌥=increase markdown header level
^⌘↩Break line at cursor and add Markdown hard line break (new)⌘⌥-decrease markdown header level
^<Make selected text into paired HTML tag. Allows attributes, only dupes first word into closing tag (caveat: overwrites your pasteboard)^⌥↩Add hard break for current line and insert newline below (new)
⌥rrepeat character before cursor^⌘↩Break line at cursor and add Markdown hard line break (new)
⌘⇧⌦Forward delete to end of paragraph^<Make selected text into paired HTML tag. Allows attributes, only dupes first word into closing tag (caveat: overwrites your pasteboard)
⌘⇧⌫Delete to beginning of paragraph⌥rrepeat character before cursor
⌘⌥7Right mouse click (useless, doesn’t maintain cursor position)⌘⇧⌦Forward delete to end of paragraph
⌘⇧⌫Delete to beginning of paragraph
⌘⌥7Right mouse click (useless, doesn’t maintain cursor position)
@@ -277,34 +291,34 @@ Any open applications will need to be re-started before the key bindings will ta - Commenting commands (^⌘c) + Commenting commands (^⌘c) - ^⌘c - - / - comment with “//” + ^⌘c + + / + comment with “//” - ^⌘c - - \ - comment with “#” + ^⌘c + + \ + comment with “#” - ^⌘c - - ! - HTML commenting + ^⌘c + + ! + HTML commenting - ^⌘c - - * - Css Commenting + ^⌘c + + * + Css Commenting @@ -321,164 +335,164 @@ Any open applications will need to be re-started before the key bindings will ta - Multi-stroke Markdown commands (^⌘w) + Multi-stroke Markdown commands (^⌘w) - ^⌘w - - ␍ - force carriage return in text field + ^⌘w + + ␍ + force carriage return in text field - ^⌘w - - ⇥ - force tab in text field + ^⌘w + + ⇥ + force tab in text field - ^⌘w - - \ - insert reference link [selection][[cursor]] + ^⌘w + + \ + insert reference link [selection][[cursor]] - ^⌘w - - \ - insert reference [selection]: [cursor] + ^⌘w + + \ + insert reference [selection]: [cursor] - ^⌘w - - + - Unordered list item with + ^⌘w + + + + Unordered list item with - ^⌘w - - - - Unordered list item with - + ^⌘w + + - + Unordered list item with - - ^⌘w - - * - Unordered list item with * + ^⌘w + + * + Unordered list item with * - ^⌘w - - 8 - convert current numbered list item to bullet, handles indentation + ^⌘w + + 8 + convert current numbered list item to bullet, handles indentation - ^⌘w - - 1 - convert current bullet list item to numbered + ^⌘w + + 1 + convert current bullet list item to numbered - Headlines (removes leading whitespace after inserting hashmarks) (h) - + Headlines (removes leading whitespace after inserting hashmarks) (h) + - ^⌘w - h - 1 - # + ^⌘w + h + 1 + # - ^⌘w - h - 2 - ## + ^⌘w + h + 2 + ## - ^⌘w - h - 3 - ### + ^⌘w + h + 3 + ### - ^⌘w - h - 4 - #### + ^⌘w + h + 4 + #### - ^⌘w - h - 5 - ##### + ^⌘w + h + 5 + ##### - ^⌘w - h - 6 - ###### + ^⌘w + h + 6 + ###### - + - Markdown link (l) - + Markdown link (l) + - ^⌘w - l - t - create a link for selected text, cursor between () [selected text]([cursor]) ( links without selected text first, these can produce a mess using multiple clipboards make a text selection before you run them) + ^⌘w + l + t + create a link for selected text, cursor between () [selected text]([cursor]) ( links without selected text first, these can produce a mess using multiple clipboards make a text selection before you run them) - ^⌘w - l - c - create a link for selected text, inserting clipboard as url [[cursor]selected text](clipboard contents) + ^⌘w + l + c + create a link for selected text, inserting clipboard as url [[cursor]selected text](clipboard contents) - + - Link as image (i) - + Link as image (i) + - ^⌘w - i - t - same as lt, but with image syntax ![selected text]([cursor]) + ^⌘w + i + t + same as lt, but with image syntax ![selected text]([cursor]) - ^⌘w - i - c - same as lc, but with image syntax ![selected text](clipboard) + ^⌘w + i + c + same as lc, but with image syntax ![selected text](clipboard) - + - Reference links (:) - + Reference links (:) + - ^⌘w - : - t - create a reference from selected text + ^⌘w + : + t + create a reference from selected text - ^⌘w - : - c - create a reference from selected text, clipboard as url + ^⌘w + : + c + create a reference from selected text, clipboard as url - + @@ -495,72 +509,72 @@ Any open applications will need to be re-started before the key bindings will ta - HTML commands (^⌘e) + HTML commands (^⌘e) - ^⌘e - - = - =“[cursor]” + ^⌘e + + = + =“[cursor]” - ^⌘e - - e - entity &[cursor]; + ^⌘e + + e + entity &[cursor]; - ^⌘e - - / - http:// + ^⌘e + + / + http:// - ^⌘e - - t - Make previous word into paired HTML tag + ^⌘e + + t + Make previous word into paired HTML tag - HTML Links (a) - + HTML Links (a) + - ^⌘e - a - t - Insert HTML link for selected text, leave cursor in the href with “http://” selected + ^⌘e + a + t + Insert HTML link for selected text, leave cursor in the href with “http://” selected - ^⌘e - a - c - Insert HTML link with clipboard as href + ^⌘e + a + c + Insert HTML link with clipboard as href - + - HTML Image (i) - + HTML Image (i) + - ^⌘e - i - t - Insert image tag, any selected text is alt text, leave cursor in src attribute + ^⌘e + i + t + Insert image tag, any selected text is alt text, leave cursor in src attribute - ^⌘e - i - c - Insert image tag, clipboard as src, any selected text as alt, leave cursor at beginning of alt attribute + ^⌘e + i + c + Insert image tag, clipboard as src, any selected text as alt, leave cursor at beginning of alt attribute - + @@ -577,74 +591,73 @@ Any open applications will need to be re-started before the key bindings will ta - Surround commands (^⌘s) + Surround commands (^⌘s) - ^⌘s - - ( - wrap () with spaces + ^⌘s + + ( + wrap () with spaces - ^⌘s - - ) - wrap () no spaces + ^⌘s + + ) + wrap () no spaces - ^⌘s - - \ - wrap [] with spaces + ^⌘s + + \ + wrap [] with spaces - ^⌘s - - \ - wrap [] no spaces + ^⌘s + + \ + wrap [] no spaces - ^⌘s - - { - wrap {} with spaces + ^⌘s + + { + wrap {} with spaces - ^⌘s - - } - wrap {} no spaces + ^⌘s + + } + wrap {} no spaces - ^⌘s - - < - wrap <> with spaces + ^⌘s + + < + wrap <> with spaces - ^⌘s - - > - wrap <> no spaces + ^⌘s + + > + wrap <> no spaces - ^⌘s - - ’ - wrap single quotes + ^⌘s + + ’ + wrap single quotes - ^⌘s - - ` - wrap backticks + ^⌘s + + ` + wrap backticks - This documentation is generated automatically from the comments and commands in the DefaultKeyBinding.dict file. The script `document_keybindings.rb` is free for use, but it's specifically designed for use with my formatting in the bindings plist (i.e. it's a little finicky). -- cgit v1.2.3