Duplicate and delete Xcode 9.x strings

Up to Xcode 8.0, you could configure the IDETextKeyBindingSet.plist file. However, now it seems that modifying this file causes Xcode to stop working normally (for example, the arrow keys stop working), and it seems that creating your own keyboard shortcuts is no longer possible.

Xcode has never had duplicate lines and insert labels. Previously, you could add them to IDETextKeyBindingSet.plist, adding the following to the right places:

<key>Insert New Line Below</key> <string>moveToEndOfLine:, insertNewline:</string> <key>Insert New Line Above</key> <string>moveUp:, moveToEndOfLine:, insertNewline:</string> <key>Duplicate Current Line</key> <string>selectLine:, copy:, moveToEndOfLine:, insertNewline:, paste:, deleteBackward:</string> <key>Delete Current Line</key> <string>selectLine:, delete:</string> <string>selectLine:, delete:</string> 

Does anyone know how to achieve the same in Xcode 8.0 or higher?

I wonder if developers use Apple Xcode? And if they check Kara? Or are they prohibited from doing this under employment contracts?

UPDATE: In Xcode 9.x, it seems to work again.

UPDATE: In Xcode 10.0, it is broken again.

UPDATE: In Xcode 10.1, it still does not work, and copying / pasting partially does not work, that is, it does not always work. (I'm still in the High Sierra)

+12
xcode8
source share
3 answers

Confirmed, still working in Xcode 10.3 on macOS Mojave 10.14.6

  1. open /Applications/Xcode.app/Contents/Frameworks/IDEKit.framework/Versions/A/Resources/IDETextKeyBindingSet.plist

  2. Add the following lines to the root dictionary

  <key>Sublime 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> 
  1. restart xcode
  2. go to Key Bindings settings and assign any shortcut to three new commands. Just find their key .

It is a pity that in the 21st century you still have to manually add such basic shortcuts.

Protest

The steps should be repeated after each Xcode update.

+30
source share

The above answer seems to be broken in Xcode 9.

Here is another solution I checked that works in Xcode 9 GM:

 <key>Custom Commands</key> <dict> <key>Duplicate Current Line</key> <string>moveToBeginningOfLine:, deleteToEndOfLine:, yank:, insertNewline:, moveToBeginningOfLine:, yank:</string> </dict> 
+8
source share

The previous answer left erroneous spaces when I tried. This works for me in Xcode 9:

 selectLine:, copy:, moveToBeginningOfLine:, paste:, moveToEndOfLine: 
+3
source share

All Articles