Created
November 8, 2011 23:45
-
-
Save ttscoff/1349738 to your computer and use it in GitHub Desktop.
Flexible DefaultKeyBinding trick to continue plain text lists
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
// Add to (or create) ~/Library/KeyBindings/DefaultKeyBinding.dict | |
// Incorporated change by Lri to not require additional words on the line to work | |
// fixed to handle first character of list item being non-alphanumeric | |
// Issues: | |
// If there are more than one symbols ([[, ![, etc.) at the beginning of the line, anything beyond the first one is captured and added to new line | |
// FIXED: Entering more than one blank item in a row and then using ⌘Z leaves a placeholder character on the previous line. | |
{ | |
// Command Option Enter | |
// continue a list item with indentation and | |
// include the same delimiter as the current line | |
"~@\U000D" = ( breakUndoCoalescing, | |
moveToEndOfParagraph:, | |
insertText:, "x", | |
moveToBeginningOfParagraph:, | |
selectWord:, | |
moveRightAndModifySelection:, | |
moveWordForwardAndModifySelection:, | |
moveWordBackwardAndModifySelection:, | |
moveLeftAndModifySelection:, | |
setMark:, | |
deleteToMark:, | |
yank:, | |
moveToEndOfParagraph:, | |
deleteBackward:, | |
insertNewlineIgnoringFieldEditor:, | |
yank:, | |
insertText:, " ", | |
selectWord:, | |
insertText:, " "); | |
} |
It still leaves the placeholder on undo. Indent a line with `1.` at the beginning, hit command-option enter twice, then undo.
Oh man, I just learned that breakUndoCoalescing works in keybindings. And you know where? From Lri.
P.S. the extra "x" problem is fixed now.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
"~@\U000D" = (moveToEndOfParagraph:, insertText:, "x", moveToBeginningOfParagraph:, selectWord:, moveRightAndModifySelection:, moveWordForwardAndModifySelection:, moveWordBackwardAndModifySelection:, setMark:, deleteToMark:, yank:, moveToEndOfParagraph:, deleteBackward:, insertNewlineIgnoringFieldEditor:, yank:);
Fixed