Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
272 lines (246 sloc) 17.1 KB
{ // General
// > defaults write -g NSTextKillRingSize -string 6
// replace yank: command with yankAndSelect for use with the kill ring
"^y" = (yankAndSelect:);
// uppercase word
"^U" = (uppercaseWord:, moveWordForward:, moveWordBackward:);
// lowercase word
"^~u" = (lowercaseWord:, moveWordForward:, moveWordBackward:);
// titlecase word
"^T" = (capitalizeWord:, moveWordForward:, moveWordBackward:);
// uppercase current paragraph
"^~U" = (setMark:, selectParagraph:, uppercaseWord:, swapWithMark:);
// lowercase current paragraph
// "^~u" = (setMark:, selectParagraph:, lowercaseWord:, swapWithMark:);
// titlecase paragraph
"^~t" = (setMark:, selectParagraph:, capitalizeWord:, swapWithMark:);
// delete word before cursor
"^w" = (deleteWordBackward:);
// select word
"~w" = (selectWord:);
// select entire line/paragraph
"~S" = (moveToBeginningOfParagraph:, moveToEndOfParagraphAndModifySelection:, moveRightAndModifySelection:);
// select from beginning of paragrah to last character
"~s" = (moveToBeginningOfParagraph:, moveToEndOfParagraphAndModifySelection:);
// delete line/paragraph
"~d" = (selectParagraph:, delete:, moveToBeginningOfParagraph:);
// copy paragraph
"~y" = (setMark:, moveToBeginningOfParagraph:, moveToEndOfParagraphAndModifySelection:, copy:, swapWithMark:);
// cut paragraph
"~x" = (moveToBeginningOfParagraph:, moveToEndOfParagraphAndModifySelection:, cut:);
// paste paragraph below
"~p" = (moveToEndOfParagraph:,moveRight:,insertNewline:,moveLeft:, paste:);
// paste paragraph above
"~P" = (moveToBeginningOfParagraph:, moveLeft:, paste:);
// select to beginning of paragraph and copy
"^A" = (moveToBeginningOfParagraphAndModifySelection:, copy:);
// select to end of paragraph and copy
"^E" = (moveToEndOfParagraphAndModifySelection:, copy:);
// cut to beginning of paragraph
"~q" = (moveToBeginningOfParagraphAndModifySelection:, cut:);
// cut to end of paragraph
"~k" = (moveToEndOfParagraphAndModifySelection:, cut:);
// blank line after current
"~o" = (moveToEndOfParagraph:, insertNewline:);
// blank line before current
"~O" = (moveToBeginningOfParagraph:, moveLeft:, insertNewline:);
// move line up
"^@k" = (selectParagraph:, setMark:, deleteToMark:, moveLeft:, moveToBeginningOfParagraph:, yank:, moveLeft:, selectToMark:, moveLeft:);
// move line down
"^@j" = (selectParagraph:, setMark:, deleteToMark:, moveToEndOfParagraph:, moveRight:, setMark:, yank:, moveLeft:, selectToMark:);
// indent line
"^@l" = (setMark:, moveToBeginningOfParagraph:, insertText:, "\t", swapWithMark:, moveRight:);
// outdent line (one tab or char)
"^@h" = (setMark:, moveToBeginningOfParagraph:, moveRight:, deleteBackward:, swapWithMark:, moveLeft:);
// > same commands but with arrow keys
// move line up
"^@\Uf700" = (selectParagraph:, setMark:, deleteToMark:, moveLeft:, moveToBeginningOfParagraph:, yank:, moveLeft:, selectToMark:, moveLeft:);
// move line down
"^@\Uf701" = (selectParagraph:, setMark:, deleteToMark:, moveToEndOfParagraph:, moveRight:, setMark:, yank:, moveLeft:, selectToMark:);
// indent line
"^@\UF703" = (setMark:, moveToBeginningOfParagraph:, insertText:, "\t", swapWithMark:, moveRight:);
// outdent line (one tab or char)
"^@\UF702" = (setMark:, moveToBeginningOfParagraph:, moveRight:, deleteBackward:, swapWithMark:, moveLeft:);
// > Control-shift-command-left arrow
// Full outdent - Deletes all leading space (or first word) of line/paragraph
"^$@\UF702" = (setMark:, moveToBeginningOfParagraph:, selectWord:, delete:, swapWithMark:, moveLeft:);
// modify selection up by paragraph (Command Option Shift Up)
"@~$\Uf700" = (selectParagraph:, moveParagraphBackwardAndModifySelection:);
// modify selection down by paragraph (Command Option Shift Down)
"@~$\Uf701" = (selectParagraph:, moveParagraphForwardAndModifySelection:);
// modify selection left by word
"^~$\UF702" = (selectWord:, moveWordLeftAndModifySelection:);
// modify selection right by word
"^~$\UF703" = (selectWord:, moveWordRightAndModifySelection:);
// TextMate Command-Return (Command Enter)
"@\U000D" = (moveToEndOfParagraph:, insertNewline:);
// Insert blank line above paragraph (Command Shift Enter)
"@$\U000D" = (moveToBeginningOfParagraph:, moveLeft:, insertNewline:);
// > this will kill non alphanumeric symbols and punctuation, use only on *words*
// hyphenate next space and move to next word
"~_" = (selectWord:,moveRight:,setMark:,moveWordRight:,moveWordLeft:,moveLeft:,selectWord:,insertText:,"-",moveWordRight:);
// bookmark
"~1" = (setMark:);
// jump to bookmark
"~2" = (swapWithMark:,centerSelectionInVisibleArea:);
// > Command Option Enter
// Continue a list item with indentation and include the same delimiter
"~@\U000D" = ( breakUndoCoalescing, moveToEndOfParagraph:, insertText:, "x", moveToBeginningOfParagraph:, selectWord:, moveRightAndModifySelection:, moveWordForwardAndModifySelection:, moveWordBackwardAndModifySelection:, moveLeftAndModifySelection:, setMark:, deleteToMark:, yank:, moveToEndOfParagraph:, deleteBackward:, insertNewlineIgnoringFieldEditor:, deleteToBeginningOfParagraph:, yank:, insertText:, " ", selectWord:, insertText:, " ");
// > Shift Tab
// remove one tab (or character) from start of line (outdent)
"$\U0009" = (setMark:, moveToBeginningOfParagraph:, moveRight:, deleteBackward:, swapWithMark:, moveLeft:);
"^@c" = { // Commenting commands
// comment with "//"
"/" = (setMark:, moveToBeginningOfParagraph:, insertText:, "// ", swapWithMark:, moveRight:, moveRight:, moveRight:);
// comment with "#"
"\\" = (setMark:, moveToBeginningOfParagraph:, insertText:, "# ", swapWithMark:, moveRight:, moveRight:);
// Html Commenting
"!" = (setMark:, moveToBeginningOfParagraph:, insertText:, "<!-- ", moveToEndOfParagraph:, insertText:, " -->", swapWithMark:, moveRight:, moveRight:, moveRight:, moveRight:, moveRight:);
// Css Commenting
"*" = (setMark:, moveToBeginningOfParagraph:, insertText:, "/* ", moveToEndOfParagraph:, insertText:, " */", swapWithMark:, moveRight:, moveRight:, moveRight:);
};
// bold selection (Markdown)
"@~b" = (selectWord:, setMark:, swapWithMark:, deleteToMark:, insertText:, "**", yank:, insertText:, " ", moveLeft:, insertText:, "**", moveRight:, deleteBackward:);
// italicize selection (Markdown)
"@~i" = (selectWord:, setMark:, swapWithMark:, deleteToMark:, insertText:, "*", yank:, insertText:, " ", moveLeft:, insertText:, "*", moveRight:, deleteBackward:);
// increase markdown header level
"@~=" = (setMark:, moveToBeginningOfParagraph:, insertText:, "# ", selectWord:, delete:, swapWithMark:, moveRight:);
// decrease markdown header level
"@~-" = (setMark:, moveToBeginningOfParagraph:, deleteForward:, swapWithMark:, moveLeft:);
"^@w" = { // Multi-stroke Markdown commands
// force carriage return in text field
"\U000A" = (insertNewlineIgnoringFieldEditor:);
// force tab in text field
"\U0009" = (insertText:, "\t");
// insert reference link `[selection][[cursor]]`
"[" = (setMark:, swapWithMark:, deleteToMark:, insertText:, " [", moveLeft:, deleteBackward:, moveRight:, yank:, insertText:, " ", moveLeft:, insertText:, "][]", moveRight:, deleteBackward:, moveLeft:);
// insert reference `[selection]: [cursor]`
"]" = (setMark:, swapWithMark:, deleteToMark:, insertText:, " [", moveLeft:, deleteBackward:, moveRight:, yank:, insertText:, " ", moveLeft:, insertText:, "]: ", moveRight:, deleteBackward:, deleteForward:);
// Unordered list item with +
"+" = (setMark:, moveToBeginningOfParagraph:, insertText:, "+ ", swapWithMark:, moveRight:, moveRight:);
// Unordered list item with -
"-" = (setMark:, moveToBeginningOfParagraph:, insertText:, "- ", swapWithMark:, moveRight:, moveRight:);
// Unordered list item with *
"*" = (setMark:, moveToBeginningOfParagraph:, insertText:, "* ", swapWithMark:, moveRight:, moveRight:);
// convert current numbered list item to bullet, handles indentation
"8" = (breakUndoCoalescing, setMark:, moveToEndOfParagraph:, insertText:, "x", moveToBeginningOfParagraph:, moveWordForward:, moveRight:, moveWordForward:, moveWordBackward:, moveWordBackwardAndModifySelection:, insertText:, "* ", moveToEndOfParagraph:, deleteBackward:, swapWithMark:, moveLeft:);
// convert current bullet list item to numbered
"1" = (breakUndoCoalescing, setMark:, moveToEndOfParagraph:, insertText:, "x", moveToBeginningOfParagraph:, moveWordForward:, moveWordBackward:, moveLeftAndModifySelection:, moveLeftAndModifySelection:, insertText:, "1. ", moveToEndOfParagraph:, deleteBackward:, swapWithMark:, moveRight:);
"h" = { // Headlines (removes leading whitespace after inserting hashmarks)
// #
"1" = (setMark:, moveToBeginningOfParagraph:, insertText:, "# ", selectWord:, insertText:, " ",swapWithMark:, moveToEndOfParagraph:);
// ##
"2" = (setMark:, moveToBeginningOfParagraph:, insertText:, "## ", selectWord:, insertText:, " ", swapWithMark:, moveToEndOfParagraph:);
// ###
"3" = (setMark:, moveToBeginningOfParagraph:, insertText:, "### ", selectWord:, insertText:, " ", swapWithMark:, moveToEndOfParagraph:);
// ####
"4" = (setMark:, moveToBeginningOfParagraph:, insertText:, "#### ", selectWord:, insertText:, " ", swapWithMark:, moveToEndOfParagraph:);
// #####
"5" = (setMark:, moveToBeginningOfParagraph:, insertText:, "##### ", selectWord:, insertText:, " ", swapWithMark:, moveToEndOfParagraph:);
// ######
"6" = (setMark:, moveToBeginningOfParagraph:, insertText:, "###### ", selectWord:, insertText:, " ", swapWithMark:, moveToEndOfParagraph:);
};
// > links
// > without selected text first, these can produce a mess using multiple clipboards
// > make a text selection before you run them
"l" = { // Markdown link
// create a link for selected text, cursor between () `[selected text]([cursor])`
"t" = (setMark:, breakUndoCoalescing:, moveRight:, insertText:, " ", deleteToMark:, insertText:, " [", moveLeft:, deleteBackward:, moveRight:, yank:, moveLeft:, insertText:, "]()", moveRight:, deleteBackward:, moveLeft:, setMark:, insertText:, "http://", selectToMark:); // link text
// create a link for selected text, inserting clipboard as url `[[cursor]selected text](clipboard contents)`
"c" = (setMark:, breakUndoCoalescing:, moveRight:, insertText:, " ", deleteToMark:, insertText:, " [", moveLeft:, deleteBackward:, moveRight:, yank:, moveLeft:, insertText:, "](", setMark:, pasteAsPlainText:, insertText:, ")", moveRight:, deleteBackward:, moveLeft:, selectToMark:); // link with clipboard
};
"i" = { // Link as image
// TODO: Apply the fix from l,t/c above to avoid inserting the kill buffer when there's no selection
// same as lt, but with image syntax `![selected text]([cursor])`
"t" = (setMark:, swapWithMark:, deleteToMark:, insertText:, "![", yank:, insertText:, " ", moveLeft:, insertText:, "]()", moveRight:, deleteBackward:, moveLeft:); // image link for text
// same as lc, but with image syntax `![selected text](clipboard)`
"c" = (setMark:, swapWithMark:, deleteToMark:, insertText:, "![", yank:, setMark:, insertText:, " ", moveLeft:, insertText:, "](", pasteAsPlainText:, insertText:, ")", moveRight:, deleteBackward:, swapWithMark:);
};
":" = { // Reference links
// create a reference from selected text
"t" = (setMark:, swapWithMark:, deleteToMark:, insertText:, " [", moveLeft:, deleteBackward:, moveRight:, yank:, insertText:, " ", moveLeft:, insertText:, "]: ", moveRight:, deleteBackward:);
// create a reference from selected text, clipboard as url
"c" = (setMark:, swapWithMark:, deleteToMark:, insertText:, " [", moveLeft:, deleteBackward:, moveRight:, yank:, insertText:, " ", moveLeft:, insertText:, "]: ", pasteAsPlainText:, moveRight:, deleteBackward:, swapWithMark:);
};
};
"^@e" = { // HTML commands
// ="[cursor]"
"=" = (insertText:, "=\"\"", moveLeft:);
// entity &[cursor];
"e" = (insertText:, "&;", moveLeft:);
// http://
"/" = (insertText:, "http://");
// Make previous word into paired HTML tag
"t" = ( "setMark:", "moveWordBackward:", "deleteToMark:", "insertText:", "<", "yank:", "insertText:", ">", "setMark:", "insertText:", "</", "yank:", "insertText:", ">", "swapWithMark:");
"a" = { // HTML Links
// Insert HTML link for selected text, leave cursor in the href with "http://" selected
"t" = ( setMark:, swapWithMark:, deleteToMark:, insertText:, "<a href=\"", setMark:, insertText:, "\">", yank:, insertText:, "</a>", swapWithMark:, setMark:, insertText:, "http://", selectToMark: );
// Insert HTML link with clipboard as href
"c" = ( setMark:, swapWithMark:, deleteToMark:, insertText:, "<a href=\"", paste:, insertText:, "\">", yank:, insertText:, "</a>" );
};
"i" = { // HTML Image
// Insert image tag, any selected text is alt text, leave cursor in src attribute
"t" = ( setMark:, swapWithMark:, deleteToMark:, insertText:, "<img src=\"", setMark:, insertText:, "\" alt=\"", yank:, insertText:, "\">", swapWithMark: );
// Insert image tag, clipboard as src, any selected text as alt, leave cursor at beginning of alt attribute
"c" = ( setMark:, swapWithMark:, deleteToMark:, insertText:, "<img src=\"", paste:, insertText:, "\" alt=\"", setMark:, yank:, insertText:, "\">", swapWithMark: );
};
};
"^@s" = { // Surround commands
// 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:);
};
"$\U001B" = { // Vim Example commands (A little vim, just as an example)
// paste after
"p" = (moveToEndOfParagraph:,moveRight:,insertNewline:,moveLeft:, yank:);
// paste before
"P" = (moveToBeginningOfParagraph:, moveLeft:, yank:);
// yank
"y" = (yank:);
"d" = { // Delete
// 'dd' delete line/paragraph
"d" = (setMark:, selectParagraph:, delete:, delete:, swapWithMark:);
// 'd$' delete from cursor to end of graf
"$" = (moveToEndOfParagraphAndModifySelection:, delete:);
// 'd0' delete to beginning of paragraph
"0" = (moveToBeginningOfParagraphAndModifySelection:, delete:);
// 'd^' delete to beginning of paragraph
"^" = (moveToBeginningOfParagraphAndModifySelection:, delete:);
};
"5" = { // Repeat 5 times
"d" = { // Delete
// 'dd' delete line/paragraph
"d" = ( selectParagraph:, delete:, delete:, moveRight:, selectParagraph:, delete:, delete:, moveRight:, selectParagraph:, delete:, delete:, moveRight:, selectParagraph:, delete:, delete:, moveRight:, selectParagraph:, delete:, delete:, moveRight:);
};
// paste after
"p" = ( moveToEndOfParagraph:, moveRight:, insertNewline:, moveLeft:, yank:, moveToEndOfParagraph:, moveRight:, insertNewline:, moveLeft:, yank:, moveToEndOfParagraph:, moveRight:, insertNewline:, moveLeft:, yank:, moveToEndOfParagraph:, moveRight:, insertNewline:, moveLeft:, yank:, moveToEndOfParagraph:, moveRight:, insertNewline:, moveLeft:, yank:);
// paste before
"P" = ( moveToBeginningOfParagraph:, moveLeft:, yank:, moveToBeginningOfParagraph:, moveLeft:, yank:, moveToBeginningOfParagraph:, moveLeft:, yank:, moveToBeginningOfParagraph:, moveLeft:, yank:, moveToBeginningOfParagraph:, moveLeft:, yank:);
// yank
"y" = ( yank:, yank:, yank:, yank:, yank:);
};
};
// repeat character before cursor
"~r" = (moveLeftAndModifySelection:, copy:, moveRight:, paste:);
// Forward delete to end of paragraph
"@\Uf728" = (deleteToEndOfParagraph:);
}
Something went wrong with that request. Please try again.