Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xcode Go to next line hotkey (like intellij's shift enter)

I've been programming on a Windows machine for quite a while using Jet Brains IDEs (IntelliJ, Android Studio, WebStorm). I just bought a Macbook and I'm trying to use Xcode to develop on it. My most used hotkey by far is Shift-Enter to start a new line underneath the line where the cursor is. Without the shortcut, I have to CMD-rightarrow, add a semicolon if needed, and then press enter. Is there a shortcut like this in Xcode? If not and thousands of developers use xcode, am I just lazy and have a bad habit? Is there a easier way to do this?

Thanks a bunch

like image 489
Geordi Dosher Avatar asked Jan 01 '16 18:01

Geordi Dosher


2 Answers

Such a hotkey is not available in Xcode. Since you are new to OS X, I should tell you that emacs shortcuts are available in Xcode and throughout the OS. So, for example, in your case the quickest way to get what you want would be Ctrl-E (move to end of line) followed by enter. You can switch your caps lock and control key easily in System Preferences to make this easier. Check this link for a full list of these bindings. I have found them supremely useful.

like image 110
davidseibert Avatar answered Nov 18 '22 15:11

davidseibert


Try this:

  1. Copy '/Applications/Xcode.app/Contents/Frameworks/IDEKit.framework/Resources/IDETextKeyBindingSet.plist' to desktop.

  2. Add following contents into the .plist file:

    <key>My Custom Actions</key>
    <dict>
    <key>Insert Line Below</key>
    <string>moveToEndOfLine:, insertNewline:</string>
    <key>Insert Line Above</key>
    <string>moveUp:, moveToEndOfLine:, insertNewline:</string>
    </dict>
  1. Copy back the modified file. sudo cp ~/Desktop/IDETextKeyBindingSet.plist /Applications/Xcode.app/Contents/Frameworks/IDEKit.framework/Resources/IDETextKeyBindingSet.plist

  2. Restart the Xcode and perform key binding.

like image 20
lzh_327 Avatar answered Nov 18 '22 16:11

lzh_327