Skip to content

Instantly share code, notes, and snippets.

@emotality
Last active August 20, 2025 18:31
Show Gist options
  • Save emotality/b1bcb2bb8a07921f9c8cad1c969daedf to your computer and use it in GitHub Desktop.
Save emotality/b1bcb2bb8a07921f9c8cad1c969daedf to your computer and use it in GitHub Desktop.

Revisions

  1. emotality revised this gist Jul 9, 2022. 1 changed file with 7 additions and 0 deletions.
    7 changes: 7 additions & 0 deletions duplicate_line_xcode.md
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,10 @@
    **NOTE (2022-07-09):** Xcode finally added this functionality in Xcode 14, [please see release notes here](https://developer.apple.com/documentation/xcode-release-notes/xcode-14-release-notes):

    **New Features in Xcode 14 Beta 3**
    When editing code, the Edit > Duplicate menu item and its corresponding keyboard shortcut now duplicate the selected text — or the line that currently contains the insertion point, if no text is selected. (8614499) (FB5618491)

    ---

    # Xcode line duplicate

    #### Bind keys to duplicate lines in Xcode
  2. emotality revised this gist Apr 26, 2022. 1 changed file with 7 additions and 5 deletions.
    12 changes: 7 additions & 5 deletions duplicate_line_xcode.md
    Original file line number Diff line number Diff line change
    @@ -2,16 +2,18 @@

    #### Bind keys to duplicate lines in Xcode

    1. Open below directory in Finder with <kbd>Cmnd</kbd> + <kbd>Shift</kbd> + <kbd>G</kbd>
    1. Close Xcode

    2. Open below directory in Finder with <kbd>Cmnd</kbd> + <kbd>Shift</kbd> + <kbd>G</kbd>

    ```
    /Applications/Xcode.app/Contents/Frameworks/IDEKit.framework/Versions/A/Resources/
    ```

    2. Open `IDETextKeyBindingSet.plist` with a text editor.
    3. Open `IDETextKeyBindingSet.plist` with a text editor.


    3. Add this in:
    4. Add this in:

    ```xml
    <key>Duplication</key>
    @@ -25,7 +27,7 @@
    </dict>
    ```

    4. Open Xcode and go to `Xcode preferences` -> `Key Bindings` -> `Text` tab -> Scroll till you see `Duplication`
    5. Open Xcode and go to `Xcode preferences` -> `Key Bindings` -> `Text` tab -> Scroll till you see `Duplication`


    5. Click on `Duplicate Current Line`, add a shortcut for it, eg. <kbd>Cmnd</kbd> + <kbd>D</kbd> (remove any other bindings for this key)
    6. Click on `Duplicate Current Line`, add a shortcut for it, eg. <kbd>Cmnd</kbd> + <kbd>D</kbd> (remove any other bindings for this key)
  3. emotality revised this gist Jun 1, 2021. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions duplicate_line_xcode.md
    Original file line number Diff line number Diff line change
    @@ -25,7 +25,7 @@
    </dict>
    ```

    4. Open Xcode and go to `Xcode preferences` -> `Key Bindings` -> `Text tab` -> Scroll till you see `Duplication`
    4. Open Xcode and go to `Xcode preferences` -> `Key Bindings` -> `Text` tab -> Scroll till you see `Duplication`


    5. Click on `Duplicate Current Line`, add a shortcut for it, eg. `Cmd + D` (remove any other bindings for this key)
    5. Click on `Duplicate Current Line`, add a shortcut for it, eg. <kbd>Cmnd</kbd> + <kbd>D</kbd> (remove any other bindings for this key)
  4. emotality revised this gist Sep 27, 2018. 2 changed files with 14 additions and 14 deletions.
    9 changes: 0 additions & 9 deletions IDETextKeyBindingSet.plist
    Original file line number Diff line number Diff line change
    @@ -1,9 +0,0 @@
    <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>
    19 changes: 14 additions & 5 deletions duplicate_line_xcode.md
    Original file line number Diff line number Diff line change
    @@ -11,12 +11,21 @@
    2. Open `IDETextKeyBindingSet.plist` with a text editor.


    3. Add the content of [IDETextKeyBindingSet.plist](#file-idetextkeybindingset-plist) (see below) to this file

    3. Add this in:

    ```xml
    <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>
    ```

    4. Open Xcode and go to `Xcode preferences` -> `Key Bindings` -> `Text tab` -> Scroll till you see `Duplication`


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

    :sunglasses:
    5. Click on `Duplicate Current Line`, add a shortcut for it, eg. `Cmd + D` (remove any other bindings for this key)
  5. emotality revised this gist Sep 27, 2018. 1 changed file with 9 additions and 0 deletions.
    9 changes: 9 additions & 0 deletions IDETextKeyBindingSet.plist
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,9 @@
    <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>
  6. emotality revised this gist Sep 27, 2018. 1 changed file with 0 additions and 9 deletions.
    9 changes: 0 additions & 9 deletions IDETextKeyBindingSet.plist
    Original file line number Diff line number Diff line change
    @@ -1,9 +0,0 @@
    <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>
  7. emotality revised this gist Sep 27, 2018. No changes.
  8. emotality renamed this gist Sep 26, 2018. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  9. emotality revised this gist Sep 26, 2018. 2 changed files with 1 addition and 1 deletion.
    File renamed without changes.
    2 changes: 1 addition & 1 deletion xcode_duplicate_line.md
    Original file line number Diff line number Diff line change
    @@ -19,4 +19,4 @@

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

    8-)
    :sunglasses:
  10. emotality revised this gist Sep 26, 2018. 3 changed files with 22 additions and 6 deletions.
    File renamed without changes.
    6 changes: 0 additions & 6 deletions xcode_duplicate_instructions.txt
    Original file line number Diff line number Diff line change
    @@ -1,6 +0,0 @@
    1. Go to: /Applications/Xcode.app/Contents/Frameworks/IDEKit.framework/Versions/A/Resources/
    2. Open 'IDETextKeyBindingSet.plist'
    3. Add the text of 'xcode_duplicate_key.txt' to this file
    4. Go to Xcode preferences -> Key Bindings -> Text tab -> Scroll till you see Duplication
    5. Click on Duplicate Current Line, add a shortcut for it, eg. Cmnd+D (resolve any duplicate bindings)
    6. Open Xcode
    22 changes: 22 additions & 0 deletions xcode_duplicate_line.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,22 @@
    # Xcode line duplicate

    #### Bind keys to duplicate lines in Xcode

    1. Open below directory in Finder with <kbd>Cmnd</kbd> + <kbd>Shift</kbd> + <kbd>G</kbd>

    ```
    /Applications/Xcode.app/Contents/Frameworks/IDEKit.framework/Versions/A/Resources/
    ```

    2. Open `IDETextKeyBindingSet.plist` with a text editor.


    3. Add the content of [IDETextKeyBindingSet.plist](#file-idetextkeybindingset-plist) (see below) to this file


    4. Open Xcode and go to `Xcode preferences` -> `Key Bindings` -> `Text tab` -> Scroll till you see `Duplication`


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

    8-)
  11. Jean-Pierre Fourie renamed this gist Jul 16, 2016. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  12. Jean-Pierre Fourie revised this gist Jul 16, 2016. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions xcode_duplicate_key.txt
    Original file line number Diff line number Diff line change
    @@ -1,9 +1,9 @@
    <key>Duplication</key>
    <dict>
    <key>Duplicate Current Line</key>
    <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>
    <string>selectLine:, copy:, moveToEndOfLine:, insertNewline:, paste:, deleteBackward:</string>
    <key>Delete Line</key>
    <string>selectLine:, deleteBackward:</string>
    </dict>
  13. Jean-Pierre Fourie created this gist Jul 16, 2016.
    6 changes: 6 additions & 0 deletions instructions.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,6 @@
    1. Go to: /Applications/Xcode.app/Contents/Frameworks/IDEKit.framework/Versions/A/Resources/
    2. Open 'IDETextKeyBindingSet.plist'
    3. Add the text of 'xcode_duplicate_key.txt' to this file
    4. Go to Xcode preferences -> Key Bindings -> Text tab -> Scroll till you see Duplication
    5. Click on Duplicate Current Line, add a shortcut for it, eg. Cmnd+D (resolve any duplicate bindings)
    6. Open Xcode
    9 changes: 9 additions & 0 deletions xcode_duplicate_key.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,9 @@
    <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>