Skip to content

Instantly share code, notes, and snippets.

@yugaego
Last active August 14, 2018 12:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yugaego/028eb35e3d3271fd1b64954aa3c1815e to your computer and use it in GitHub Desktop.
Save yugaego/028eb35e3d3271fd1b64954aa3c1815e to your computer and use it in GitHub Desktop.
Xcode Line Actions Custom Shortcuts

Setup

Based on Stackoverflow solution

Environment

  • Xcode 9.4.1
  • MacOS 10.13.6 High Sierra

Add Commands

$ sudo vim /Applications/Xcode.app/Contents/Frameworks/IDEKit.framework/Versions/A/Resources/IDETextKeyBindingSet.plist

  <key>Custom Commands</key>
    <dict>
      <key>Cut Current Line</key>
      <string>selectLine:, cut:</string>
      <key>Copy Current Line</key>
      <string>selectLine:, copy:</string>
      <key>Duplicate Current Line</key>
      <string>selectLine:, copy:, moveToBeginningOfLine:, paste:, moveToEndOfLine:</string>
  </dict>

Add Shortcuts

  • Xcode >> Preferences >> Key Bindings
  • Filter by current line
  • Assign shortcuts. For example:
    • copy Command + Control + L
    • cut Command + Control + X
    • duplicate Command + Control + K
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment