1

Kind of a tricky one to describe. Here goes though. Open up your favourite text editor on OSX (well, Textedit, Coda 2, a Chrome textarea at least). Type a long line of text, followed by a short line. Place your cursor at the end, like this:

I am a long, long, line of text.
I am short.|

If I want to delete the line "I am short" and the line break, in Windows I'd Shift+Up, then Ctrl+Shift+End. (Similarly, Ctrl+Shift+Home would select both lines in their entirety.)

On OSX, I can Shift+Up to select the second half of the first line fine, but Cmd+Shift+Right doesn't do anything. Cmd+Shift+Left does, however, select both lines like on Windows. You can repeat the same behaviour with using Ctrl+a/e for home/end.

Why doesn't Cmd+Shift+Right work? Can I make it work? Is there a similar command which would work?

I know I can do Cmd+Shift+Left, Shift+Left and it achieves the same thing with the same number of pushes, but Shift+Up etc is pretty ingrained in my muscle memory. I still use a Windows PC on a regular basis too, so would prefer to use the same general method, and Ctrl+Shift+Home, Shift+Left on a PC is a bit more cumbersome as Home and Left aren't in the same block of keys.

4
  • Most (good) editors should support line deletion, which deletes the current line including the trailing newline, which accomplishes what you are trying to do in a single operation.
    – Gerry
    Commented Mar 14, 2013 at 12:23
  • Thanks Gerry and others. Might have to go for finding the command to delete the current line/break in the editor of my choice, and re-learn some muscle memory.
    – SpoonNZ
    Commented Mar 15, 2013 at 21:04
  • OK. I've discovered I don't just do this when deleting! Often it's if I want to duplicate the current line. I highlight as above, then Cmd-C, Cmd-V, Cmd-V, Cmd-V. Again, editors probably have commands to duplicate the current line, but having to learn particular commands is annoying - I though that we left that behind in the days of Vi ;). Thanks for your help anyway - understand it's a Mac issue, and appreciate there's probably no way around it short of changing editors or OSes.
    – SpoonNZ
    Commented Mar 18, 2013 at 20:21
  • In 2023, cmd+shift+right now works in this case -- at least in TextEdit.app. Either way I suggest retraining to (Windows): shift+home, backspace(x2). On macOS that'd be cmd+shift+left, backspace(x2).
    – Mike Clark
    Commented Dec 4, 2023 at 5:29

2 Answers 2

4

What if you want to select 78 here (after having pressed ⇧↑)?

Or if you want to select both 12 and 78, on Windows you couldn't press shift+home and shift+end.

Methods like moveToEndOfLineAndModifySelection: are unanchored in most applications, which means that they always extend selections. They are actually anchored in Xcode, TextMate, Sublime Text, and BBEdit, but I don't know any way to change the default behavior.

If you just want to make selecting and deleting lines easier, you can create ~/Library/KeyBindings/ and save a property list like this as DefaultKeyBinding.dict:

{
    "~l" = selectParagraph:;
    "~z" = (selectParagraph:, deleteBackward:);
    "~x" = (selectParagraph:, cut:);
    "~c" = (selectParagraph:, copy:);
}

After reopening applications, ⌥L should select a line. See http://www.hcs.harvard.edu/~jrus/site/cocoa-text.html and http://lri.me/keybindings.html for more information.

2

CMD SHIFT LEFT, (now let go of CMD), LEFT again is the only way I can sensibly replicate (as you already found) the function you require.

Unfortunately you might just have to accept that for certain things, differente OS do things differently, and whilst you can occasionally modify one to mimic the other, you cannot always. For example, I bet you just love using @ and " when switching between Mac and PC, or not having Delete or HOME key etc as a specific key on a short Mac keyboard. We have to just put up with these things.

My solution, as it happens, was to buy a Mac keyboard for my PC, remap the keys for things like @ etc. Not exactly a cost free workaround, but the one that provides me with the most commonality and consistency of input regardless of if I am using a desktop iMac, a Macbook, or a PC.

Another workaround might be to not select the newline in order to delete everything in 1 push, technically CMD+SHIFT+LEFT BACKSPACE BACKSPACE uses less keystrokes than either your Mac or Win methods, and is the same on both.

2
  • Thanks. The thing that bugs me is it logically should work though, right? The @/" thing isn't an issue for me, you must be on a European keyboard of some sort, right? Delete/Home/End thing I've gotten used to but this I just can't seem to :S
    – SpoonNZ
    Commented Mar 13, 2013 at 23:06
  • Yeah, UK keyboard.
    – stuffe
    Commented Mar 13, 2013 at 23:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .