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.

  • 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 Mar 14 '13 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 Mar 15 '13 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 Mar 18 '13 at 20:21

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.

| improve this answer | |

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.

| improve this answer | |
  • 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 Mar 13 '13 at 23:06
  • Yeah, UK keyboard. – stuffe Mar 13 '13 at 23:09

You must log in to answer this question.

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