Skip to content

Instantly share code, notes, and snippets.

@VadimYakovliev
Forked from emotality/duplicate_line_xcode.md
Created February 13, 2019 16:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save VadimYakovliev/9a55183e4a8e4d1e05ae5c1b04f9a3c1 to your computer and use it in GitHub Desktop.
Save VadimYakovliev/9a55183e4a8e4d1e05ae5c1b04f9a3c1 to your computer and use it in GitHub Desktop.
Xcode - Duplicate Line key binding

Xcode line duplicate

Bind keys to duplicate lines in Xcode

  1. Open below directory in Finder with Cmnd + Shift + G
/Applications/Xcode.app/Contents/Frameworks/IDEKit.framework/Versions/A/Resources/
  1. Open IDETextKeyBindingSet.plist with a text editor.

  2. Add this in:

<key>Duplication</key>
<dict>
    <key>Duplicate Current Line</key>
    <string>moveToBeginningOfLine:, deleteToEndOfLine:, yank:, insertNewline:, moveToBeginningOfLine:, yank:</string>
    <key>Duplicate Lines</key>
    <string>selectLine:, copy:, moveToEndOfLine:, insertNewline:, paste:, deleteBackward:</string>
    <key>Delete Line</key>
    <string>selectLine:, deleteBackward:</string>
</dict>
  1. Open Xcode and go to Xcode preferences -> Key Bindings -> Text tab -> Scroll till you see Duplication

  2. Click on Duplicate Current Line, add a shortcut for it, eg. Cmd + D (remove any other bindings for this key)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment