'Open a new line below current line in Xcode

Is there any easy way to open a new line below current line in Xcode text editor? Currently I have to press cmd+right and enter for this purpose. Eclipse (Shift+Enter) and vim (o) can do that with simple key combination.



Solution 1:[1]

You can take a look at this tutorial about how to add custom keyboard shortcut in Xcode ---Xcode duplicate line, then just add a new key-value Insert New Line Below Current Line moveToEndOfLine:, insertNewline: in IDETextKeyBindingSet.plist file, at last config your Key Bindings (like Shift+Enter) in Xcode.

Solution 2:[2]

I don't think XCode supports that shortcut.

Check the Key Bindings preferences. Search for "line" under the Text tab.

There are lots of "Insert Newline" commands for which you can set key combos. There's Ctrl+o, Cmd+Enter, Opt+Enter, etc. But I don't think it's possible to do natively.

Solution 3:[3]

The answer is

1. open this file

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

2. option click (context menu) and select Add Row

3. Give any name (e.g My Custom) choose **Dictionary as it's type

4. click + icon on this new dictionary. a new field will appear, enter your preferred name (e.g insert new line below).

5. enter moveToEndOfLine:, insertNewline: as it's value

6. save the file.

7. quit and relaunch Xcode

8. open preferences, go to key bindings and search for your name insert new line below

assign a shortcut.

enjoy!

enter image description here

enter image description here

NOTES if you have permissions problem in saving the file. just copy the file to your desktop, edit it, and then move the file to the location /Applications/Xcode.app/Contents/Frameworks/IDEKit.framework/Versions/A/Resources/

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Community
Solution 2 AWF4vk
Solution 3