Reputation: 366
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.
Upvotes: 16
Views: 8910
Reputation: 298
I found that moveToEndOfLine:, insertNewline:
did not work for me. Instead, this worked moveToEndOfLine:, insertLineBreak:
. I am using Xcode 13.4.1
Upvotes: 1
Reputation: 1549
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/
Upvotes: 3
Reputation: 3543
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.
Upvotes: 11
Reputation: 5890
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.
Upvotes: 3