2

I recently have started development for Swift with XCode 6. I've used Sublime Text 3 for the last couple years, and more recently have fallen in love GitHub's Atom Editor. My biggest frustration so far with XCode is the lack of a copy/cut line tool.

In the text editors I've used copy/cut commands will copy/cut the whole line if no selection is made.

So far the only alternative I have found is the following:

Ctrl + A - Move cursor to the beginning of a line
Shift + ↓ - Select the line
Ctrl + C - Copy Selection

This works, however I'm wondering if anyone has figured out an elegant way to wrap these up into one powerful copy/cut line tool

On a side note, I am also missing the move line up/down shortcuts which are also very useful.

Note: a solution described in this answer no longer works in Xcode 6.

Community
  • 1
  • 1
Unome
  • 6,750
  • 7
  • 45
  • 87

2 Answers2

6
  1. From the terminal cd into / to get to the MacHD and then go into applications,otherwise you won't get all of the applications in the list.
  2. open the file /Applications/XcodeBeta.app/Contents/Frameworks/IDEKit.framework/Resources/IDETextKeyBindingSet.plist with sudo privileges (be sure to use the correct app-directory for the version of Xcode you are using---for Xcode 6.3 beta mine was Xcode-Beta.app). You can use open . in the terminal when you get to the desired location in finder
  3. Now add the following section:

    <key>My Custom Commands</key> <dict> <key>Cut Current Line</key> <string>selectLine:, cut:</string> <key>Copy Current Line</key> <string>selectLine:, copy:</string> </dict>

Restart XCode and in the keybindings section you should be able search for cut current line and copy current line and set custom keybindings to them. The format of creating commands is actually pretty simple and intuitive.

Unome
  • 6,750
  • 7
  • 45
  • 87
  • 2
    Just a sidenote: This does **not** allow to use `command` + `x`/`c` for the new `Cut Current Line`/`Copy Current Line` functionality **and** the normal `cut`/`copy` functionality. – Binarian Mar 20 '19 at 09:47
2

On a side note, I am also missing the move line up/down shortcuts which are also very useful.

Preferences->Key Bindings
Move line up: option+command+[
Move line down: option+command+]

mretondo
  • 187
  • 1
  • 9