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.
4 Answers
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.
-
2Its a shame apple didn't think about defining custom key shortcuts. anyway thanks a lot. it helps me – Sepehr Behroozi Jun 03 '17 at 06:27
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.

- 5,810
- 3
- 37
- 70
-
2`Ctrl-o` worked for me without going into preferences. (XCode 4.5.2) – Barney Szabolcs Dec 04 '12 at 18:39
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!
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/

- 1,173
- 1
- 13
- 23
I found that moveToEndOfLine:, insertNewline:
did not work for me. Instead, this worked moveToEndOfLine:, insertLineBreak:
. I am using Xcode 13.4.1

- 140
- 3
- 8