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?
On your keyboard, press and hold the left or right Shift key and then press the End key to highlight the entire line. Press the Delete key to delete the line of text.
Shift + Control + Click First, hold Shift and Control (^) and then click where you want to select multiple lines and then start typing. One small caveat: unlike other text editors where you can click that same line to unselect the multi-line selection, Xcode doesn't support that yet.
Moving the CursorEnd – Move cursor to end of current line. Ctrl+Home – Move cursor to top of the text entry field. Ctrl+End – Move cursor to bottom of the text entry field.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With