Blog coding and discussion of coding about JavaScript, PHP, CGI, general web building etc.

Friday, January 8, 2016

Xcode: Delete line hot-key

Xcode: Delete line hot-key


I'm looking for a way to map some hot-keys to "delete the line that my cursor is on" in Xcode. I found "delete to end of line" and "delete to beginning of line" in the text key bindings, but I am missing how to completely delete the line no matter what I have selected. TextMate has this functionality mapped to Ctrl+Shift+D and I'd like the same thing if possible. Any ideas?

Answer by Ashley Clark for Xcode: Delete line hot-key


You can set up a system-wide key binding file that will apply to all Cocoa apps.

To do what you want it should like like this:

In your home folder, Library/KeyBindings/DefaultKeyBinding.dict

{      "^D" = (          "moveToBeginningOfLine:",          "deleteToEndOfLine:",      );  }  

I believe if you only want it to apply to Xcode you can name the file PBKeyBinding.dict instead but I didn't try that myself. You can read more about this system here and here.

Answer by typeoneerror for Xcode: Delete line hot-key


Thanks for the help, Ashley. After some experimentation I mapped my favorite TextMate commands (duplicate line, delete line). I created the file ~/Library/KeyBindings/PBKeyBinding.dict and added the following:

{      "^$K" = (          "selectLine:",          "cut:"      );      "^$D" = (          "selectLine:",      	"copy:",      	"moveToEndOfLine:",      	"insertNewline:",      	"paste:"      );  }  

The added "deleteBackward:" backs up one line after removing the line's content. You could probably just use "selectLine:" as well.

Answer by mclin for Xcode: Delete line hot-key


I was looking for a solution to this, and I tried Ashley Clark's, but it turns out there's an easier option using an included User Script called delete Line.

  • Open the weird menu to the left of 'help' that looks like a scroll.
  • Choose Edit User Scripts...
  • Click the Key Bindings tab
  • Expand the Text section
  • Double click the ? column next to 'Delete Line' and type your hotkey. It may warn you that you stole it from some other command but that's fine.

Done! You can do the same for Move Line Up and Move Line Down if you're an Eclipse junkie like me.

Answer by Sebastian Juarez for Xcode: Delete line hot-key


As I don't always work on the same xcode I prefer not to install scripts.

Xcode uses some sub-set of emacs commands. I use this approach to quickly delete a line. ^k (control-k) deletes from the cursor to the end of the line. Doing it twice also deletes the carriage return and takes up the next line. ^a takes you to the start of the line.

So to delete a complete line from the beginning you can use ^a^k^k.

Answer by Ixx for Xcode: Delete line hot-key


This works for me (Xcode 4.4.1):

Same steps like described here: Xcode duplicate line (Halley's answer)

But instead of:

selectLine:, copy:, moveToEndOfLine:, insertNewline:, paste:, deleteBackward:

Use:

selectLine:, moveToBeginningOfLine:, deleteToEndOfLine:

Answer by Velthune for Xcode: Delete line hot-key


Custom Keyword Set     Delete Current Line In One Hit       moveToEndOfLine:, deleteToBeginningOfLine:, deleteToEndOfParagraph:    

I suggest to create your customized dictonary in your file IDETextKeyBindingSet.plist.

So:

  • close Xcode;
  • open Terminal;
  • sudo nano /Applications/Xcode.app/Contents/Frameworks/IDEKit.framework/Resources/IDETextKeyBindingSet.plist
  • add new custom section, for instance code in top;
  • save, exit and open Xcode;
  • [Xcode > Preferences > Key Binding]
  • search ?Delete..? and create the new shortcut.

Answer by Nicronaide for Xcode: Delete line hot-key


If you're having trouble in modern Xcode (which I was) solution for this in Xcode 7.2 is to do what Opena mentioned here with screenshots or in text form via Velthune's answer. Since I wanted a more direct command I simplified the command to:

selectLine:, delete:, moveToBeginningOfLine:  

Of course in the Xcode's Preferences >> Key Bindings, you can just find the command double-click under the Key column and give it your own binding of Ctrl+Shift+D.

Here's a screenshot of what I ended up with


Fatal error: Call to a member function getElementsByTagName() on a non-object in D:\XAMPP INSTALLASTION\xampp\htdocs\endunpratama9i\www-stackoverflow-info-proses.php on line 72

0 comments:

Post a Comment

Popular Posts

Powered by Blogger.