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.* - -
| General Commands | +General Commands | ||
|---|---|---|---|
| Key | -Function | +Key | +Function |
| ^y | -replace yank: command with yankAndSelect for use with the kill ring ( defaults write -g NSTextKillRingSize -string 6) | +^y | +replace yank: command with yankAndSelect for use with the kill ring ( defaults write -g NSTextKillRingSize -string 6) | +
| ^⇧u | +uppercase word | +||
| ^⌥u | +lowercase word | ||
| ^⇧u | -uppercase word | +^⇧t | +titlecase word |
| ^⌥u | -lowercase word | +^⌥⇧u | +uppercase current paragraph |
| ^⇧t | -titlecase word | +^⌥t | +titlecase paragraph |
| ^⌥⇧u | -uppercase current paragraph | +^w | +delete word before cursor |
| ^⌥t | -titlecase paragraph | +⌥w | +select word |
| ^w | -delete word before cursor | +⌥⇧s | +select entire line/paragraph |
| ⌥w | -select word | +⌥s | +select from beginning of paragrah to last character |
| ⌥⇧s | -select entire line/paragraph | +^⌥⇧s | +select paragraph excluding leading/trailing whitespace (same as ^$@\UF701) |
| ⌥s | -select from beginning of paragrah to last character | +⌥d | +delete line/paragraph |
| ⌥d | -delete line/paragraph | +⌥y | +copy paragraph |
| ⌥y | -copy paragraph | +⌥x | +cut paragraph |
| ⌥x | -cut paragraph | +⌥p | +paste paragraph below |
| ⌥p | -paste paragraph below | +⌥⇧p | +paste paragraph above |
| ⌥⇧p | -paste paragraph above | +^⇧a | +select to beginning of paragraph and copy |
| ^⇧a | -select to beginning of paragraph and copy | +^⇧e | +select to end of paragraph and copy |
| ^⇧e | -select to end of paragraph and copy | +⌥q | +cut to beginning of paragraph |
| ⌥q | -cut to beginning of paragraph | +⌥k | +cut to end of paragraph |
| ⌥k | -cut to end of paragraph | +⌥o | +blank line after current |
| ⌥o | -blank line after current | +⌥⇧o | +blank line before current |
| ⌥⇧o | -blank line before current | +^⌘k | +move line up |
| ^⌘k | -move line up | +^⌘j | +move line down |
| ^⌘j | -move line down | +^⌘l | +indent line |
| ^⌘l | -indent line | +^⌘h | +outdent line (one tab or char) |
| ^⌘h | -outdent 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) |
| ⌥1 | -bookmark | +⌘⇧↩ | +Insert blank line above paragraph (Command Shift Enter) |
| ⌥2 | -jump 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) | +⌥1 | +bookmark |
| ⇧⇥ | -remove one tab (or character) from start of line (outdent) ( Shift Tab) | +⌥2 | +jump to bookmark |
| ⌘⌥b | -bold selection (Markdown) | +⌥⌘↩ | +Continue a list item with indentation and include the same delimiter ( Command Option Enter) |
| ⌘⌥i | -italicize selection (Markdown) | +⇧⇥ | +remove one tab (or character) from start of line (outdent) ( Shift Tab) |
| ⌘⌥= | -increase markdown header level | +⌘⌥b | +bold selection (Markdown) |
| ⌘⌥- | -decrease markdown header level | +⌘⌥i | +italicize 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) |
| ⌥r | -repeat 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 | +⌥r | +repeat character before cursor |
| ⌘⌥7 | -Right mouse click (useless, doesn’t maintain cursor position) | +⌘⇧⌦ | +Forward delete to end of paragraph | +
| ⌘⇧⌫ | +Delete to beginning of paragraph | +||
| ⌘⌥7 | +Right mouse click (useless, doesn’t maintain cursor position) | ||
[selection][[cursor]][selection][[cursor]][selection]: [cursor][selection]: [cursor][selected text]([cursor]) ( links without selected text first, these can produce a mess using multiple clipboards make a text selection before you run them)[selected text]([cursor]) ( links without selected text first, these can produce a mess using multiple clipboards make a text selection before you run them)[[cursor]selected text](clipboard contents)[[cursor]selected text](clipboard contents)