Skip to content

Instantly share code, notes, and snippets.

@ric-bianchi
Last active April 3, 2020 17:16
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ric-bianchi/5e265191ab417a13b68299c2fd73b567 to your computer and use it in GitHub Desktop.
Save ric-bianchi/5e265191ab417a13b68299c2fd73b567 to your computer and use it in GitHub Desktop.
Riccardo's customized Xcode keyboard shortcuts

Customized Xcode key bindings

Here is my customized Xcode key bindings file, which includes some custom commands.

In particular, I emulate the Eclipse shortcuts, which I find the most ergonomic I ever used.

  • Alt+Cmd+Down: duplicate current line below
  • Alt+Cmd+Up: duplicate current line above
  • Cmd+D: delete current line --> For that, I changed the default Cmd+D (EditMenu->Duplicate)

Tested on macOS 10.14.5 Mojave + Xcode 10.2

Make the key-bindings file and its parent folder editable:

cd /Applications/Xcode.app/Contents/Frameworks/IDEKit.framework/Resources
sudo chmod 777 Resources
sudo chmod 777 Versions/Current/Resources/
cd Resources
sudo chmod 664 IDETextKeyBindingSet.plist

Set the new settings

Then, copy the .plits file below to the file IDETextKeyBindingSet.plist

Sources and more info

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Cancellation</key>
<dict>
<key>Cancel</key>
<string>cancelOperation:</string>
</dict>
<key>Transformations</key>
<dict>
<key>Capitalize Word</key>
<string>capitalizeWord:</string>
<key>Lowercase Word</key>
<string>lowercaseWord:</string>
<key>Uppercase Word</key>
<string>uppercaseWord:</string>
<key>Transpose</key>
<string>transpose:</string>
</dict>
<key>Code Completion</key>
<dict>
<key>Select Next Completion</key>
<string>nextCompletion:</string>
<key>Select Previous Completion</key>
<string>previousCompletion:</string>
<key>Show Completion List</key>
<string>complete:</string>
</dict>
<key>Deletions</key>
<dict>
<key>Delete</key>
<string>delete:</string>
<key>Delete Backward</key>
<string>deleteBackward:</string>
<key>Delete Backward by Decomposing Previous Character</key>
<string>deleteBackwardByDecomposingPreviousCharacter:</string>
<key>Delete Forward</key>
<string>deleteForward:</string>
<key>Delete Subword Backward</key>
<string>deleteSubWordBackward:</string>
<key>Delete Subword Forward</key>
<string>deleteSubWordForward:</string>
<key>Delete Expression Backward</key>
<string>deleteExpressionBackward:</string>
<key>Delete Expression Forward</key>
<string>deleteExpressionForward:</string>
<key>Delete Line</key>
<string>deleteLine:</string>
<key>Delete Paragraph</key>
<string>deleteParagraph:</string>
<key>Delete Word Backward</key>
<string>deleteWordBackward:</string>
<key>Delete Word Forward</key>
<string>deleteWordForward:</string>
<key>Delete to Beginning of Document</key>
<string>deleteToBeginningOfDocument:</string>
<key>Delete to Beginning of Line</key>
<string>deleteToBeginningOfLine:</string>
<key>Delete to Beginning of Paragraph</key>
<string>deleteToBeginningOfParagraph:</string>
<key>Delete to Beginning of Text</key>
<string>deleteToBeginningOfText:</string>
<key>Delete to End of Document</key>
<string>deleteToEndOfDocument:</string>
<key>Delete to End of Line</key>
<string>deleteToEndOfLine:</string>
<key>Delete to End of Paragraph</key>
<string>deleteToEndOfParagraph:</string>
<key>Delete to End of Text</key>
<string>deleteToEndOfText:</string>
</dict>
<key>Find &amp; Replace</key>
<dict>
<key>Find Next</key>
<string>findNext:</string>
<key>Find Previous</key>
<string>findPrevious:</string>
<key>Replace</key>
<string>replace:</string>
<key>Replace All</key>
<string>replaceAll:</string>
<key>Replace and Find Next</key>
<string>replaceAndFindNext:</string>
<key>Replace and Find Previous</key>
<string>replaceAndFindPrevious:</string>
</dict>
<key>Insertions and Indentations</key>
<dict>
<key>Indent</key>
<string>indent:</string>
<key>Insert Backtab</key>
<string>insertBacktab:</string>
<key>Insert Container Break</key>
<string>insertContainerBreak:</string>
<key>Insert Double Quote without Extra Action</key>
<string>insertDoubleQuoteIgnoringSubstitution:</string>
<key>Insert Line Break</key>
<string>insertLineBreak:</string>
<key>Insert Newline</key>
<string>insertNewline:</string>
<key>Insert Newline and Leave Selection Before It</key>
<string>insertNewlineIgnoringFieldEditor:, moveBackward:</string>
<key>Insert Newline without Extra Action</key>
<string>insertNewlineIgnoringFieldEditor:</string>
<key>Insert Paragraph Separator</key>
<string>insertParagraphSeparator:</string>
<key>Insert Single Quote without Extra Action</key>
<string>insertSingleQuoteIgnoringSubstitution:</string>
<key>Insert Slash</key>
<string>insertRightToLeftSlash:</string>
<key>Insert Tab</key>
<string>insertTab:</string>
<key>Insert Tab without Extra Action</key>
<string>insertTabIgnoringFieldEditor:</string>
</dict>
<key>Line Duplications</key>
<dict>
<key>Duplicate Current Line Above</key>
<string>selectLine:, copy:, moveToEndOfLine:, insertNewline:, paste:, deleteBackward:, moveUp:</string>
<key>Duplicate Current Line Below</key>
<string>selectLine:, copy:, moveToEndOfLine:, insertNewline:, paste:, deleteBackward:</string>
</dict>
<key>Mark &amp; Yank</key>
<dict>
<key>Delete to Mark</key>
<string>deleteToMark:</string>
<key>Select to Mark</key>
<string>selectToMark:</string>
<key>Set Mark</key>
<string>setMark:</string>
<key>Swap with Mark</key>
<string>swapWithMark:</string>
<key>Yank</key>
<string>yank:</string>
<key>Yank and Select</key>
<string>yankAndSelect:</string>
</dict>
<key>Scrolling</key>
<dict>
<key>Center Selection in Visible Area</key>
<string>centerSelectionInVisibleArea:</string>
<key>Scroll Left</key>
<string>scrollTabWidthLeft:</string>
<key>Scroll Line Down</key>
<string>scrollLineDown:</string>
<key>Scroll Line Up</key>
<string>scrollLineUp:</string>
<key>Scroll Page Down</key>
<string>scrollPageDown:</string>
<key>Scroll Page Up</key>
<string>scrollPageUp:</string>
<key>Scroll Right</key>
<string>scrollTabWidthRight:</string>
<key>Scroll to Beginning of Document</key>
<string>scrollToBeginningOfDocument:</string>
<key>Scroll to End of Document</key>
<string>scrollToEndOfDocument:</string>
</dict>
<key>Selection</key>
<dict>
<key>Move Backward</key>
<string>moveBackward:</string>
<key>Move Backward Extending Selection</key>
<string>moveBackwardAndModifySelection:</string>
<key>Move Down</key>
<string>moveDown:</string>
<key>Move Down Extending Selection</key>
<string>moveDownAndModifySelection:</string>
<key>Move Forward</key>
<string>moveForward:</string>
<key>Move Forward Extending Selection</key>
<string>moveForwardAndModifySelection:</string>
<key>Move Left</key>
<string>moveLeft:</string>
<key>Move Left Extending Selection</key>
<string>moveLeftAndModifySelection:</string>
<key>Move Paragraph Backward</key>
<string>moveBackward:, moveToBeginningOfParagraph:</string>
<key>Move Paragraph Backward Extending Selection</key>
<string>moveParagraphBackwardAndModifySelection:</string>
<key>Move Paragraph Forward</key>
<string>moveForward:, moveToEndOfParagraph:</string>
<key>Move Paragraph Forward Extending Selection</key>
<string>moveParagraphForwardAndModifySelection:</string>
<key>Move Right</key>
<string>moveRight:</string>
<key>Move Right Extending Selection</key>
<string>moveRightAndModifySelection:</string>
<key>Move Subword Backward</key>
<string>moveSubWordBackward:</string>
<key>Move Subword Backward Extending Selection</key>
<string>moveSubWordBackwardAndModifySelection:</string>
<key>Move Subword Forward</key>
<string>moveSubWordForward:</string>
<key>Move Subword Forward Extending Selection</key>
<string>moveSubWordForwardAndModifySelection:</string>
<key>Move Expression Left</key>
<string>moveExpressionBackward:</string>
<key>Move Expression Left Extending Selection</key>
<string>moveExpressionBackwardAndModifySelection:</string>
<key>Move Expression Right</key>
<string>moveExpressionForward:</string>
<key>Move Expression Right Extending Selection</key>
<string>moveExpressionForwardAndModifySelection:</string>
<key>Move Up</key>
<string>moveUp:</string>
<key>Move Up Extending Selection</key>
<string>moveUpAndModifySelection:</string>
<key>Move Word Backward</key>
<string>moveWordBackward:</string>
<key>Move Word Backward Extending Selection</key>
<string>moveWordBackwardAndModifySelection:</string>
<key>Move Word Forward</key>
<string>moveWordForward:</string>
<key>Move Word Forward Extending Selection</key>
<string>moveWordForwardAndModifySelection:</string>
<key>Move Word Left</key>
<string>moveWordLeft:</string>
<key>Move Word Left Extending Selection</key>
<string>moveWordLeftAndModifySelection:</string>
<key>Move Word Right</key>
<string>moveWordRight:</string>
<key>Move Word Right Extending Selection</key>
<string>moveWordRightAndModifySelection:</string>
<key>Move to Beginning of Document</key>
<string>moveToBeginningOfDocument:</string>
<key>Move to Beginning of Document Extending Selection</key>
<string>moveToBeginningOfDocumentAndModifySelection:</string>
<key>Move to Beginning of Line</key>
<string>moveToBeginningOfLine:</string>
<key>Move to Beginning of Line Extending Selection</key>
<string>moveToBeginningOfLineAndModifySelection:</string>
<key>Move to Beginning of Paragraph</key>
<string>moveToBeginningOfParagraph:</string>
<key>Move to Beginning of Paragraph Extending Selection</key>
<string>moveToBeginningOfParagraphAndModifySelection:</string>
<key>Move to Beginning of Text</key>
<string>moveToBeginningOfText:</string>
<key>Move to Beginning of Text Extending Selection</key>
<string>moveToBeginningOfTextAndModifySelection:</string>
<key>Move to End of Document</key>
<string>moveToEndOfDocument:</string>
<key>Move to End of Document Extending Selection</key>
<string>moveToEndOfDocumentAndModifySelection:</string>
<key>Move to End of Line</key>
<string>moveToEndOfLine:</string>
<key>Move to End of Line Extending Selection</key>
<string>moveToEndOfLineAndModifySelection:</string>
<key>Move to End of Paragraph</key>
<string>moveToEndOfParagraph:</string>
<key>Move to End of Paragraph Extending Selection</key>
<string>moveToEndOfParagraphAndModifySelection:</string>
<key>Move to End of Text</key>
<string>moveToEndOfText:</string>
<key>Move to End of Text Extending Selection</key>
<string>moveToEndOfTextAndModifySelection:</string>
<key>Move to Left End of Line</key>
<string>moveToLeftEndOfLine:</string>
<key>Move to Left End of Line Extending Selection</key>
<string>moveToLeftEndOfLineAndModifySelection:</string>
<key>Move to Right End of Line</key>
<string>moveToRightEndOfLine:</string>
<key>Move to Right End of Line Extending Selection</key>
<string>moveToRightEndOfLineAndModifySelection:</string>
<key>Move Page Down</key>
<string>pageDown:</string>
<key>Move Page Down Extending Selection</key>
<string>pageDownAndModifySelection:</string>
<key>Move Page Up</key>
<string>pageUp:</string>
<key>Move Page Up Extending Selection</key>
<string>pageUpAndModifySelection:</string>
<key>Select All</key>
<string>selectAll:</string>
<key>Select Line</key>
<string>selectLine:</string>
<key>Select Paragraph</key>
<string>selectParagraph:</string>
<key>Select Word</key>
<string>selectWord:</string>
</dict>
<key>Undo/Redo</key>
<dict>
<key>Redo</key>
<string>redo:</string>
<key>Undo</key>
<string>undo:</string>
</dict>
<key>Writing Direction</key>
<dict>
<key>Make Base Writing Direction Left to Right</key>
<string>makeBaseWritingDirectionLeftToRight:</string>
<key>Make Base Writing Direction Natural</key>
<string>makeBaseWritingDirectionNatural:</string>
<key>Make Base Writing Direction Right to Left</key>
<string>makeBaseWritingDirectionRightToLeft:</string>
<key>Make Text Writing Direction Left to Right</key>
<string>makeTextWritingDirectionLeftToRight:</string>
<key>Make Text Writing Direction Natural</key>
<string>makeTextWritingDirectionNatural:</string>
<key>Make Text Writing Direction Right to Left</key>
<string>makeTextWritingDirectionRightToLeft:</string>
</dict>
</dict>
</plist>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment