OSX: modifying text selection with ⌘⇧→ and ⌘⇧←

Solution 1:

Mac doesn't use the cursor position if you have a multiple text selection, it considers the cursor is at 'all selected text'.

You can see this demonstrated if you use Cmd ⌘ Shift ⇧ instead of
Adding to the selection with Shift ⇧ includes the previous selection.

Not a fix, but a workaround might be which would move the cursor to the end of your current selection, simultaneously deselecting it, then Cmd ⌘ Shift ⇧ to select to the beginning of the line.

Solution 2:

So, the way I see it, text navigation on OS X works (and is expected to work) like this:

  1. Navigate per line (or document, i.e. huge chunks of data):

    cmd+arrow keys : moves by lines (left/right for lines, up/down for the whole document). Hold shift to select

  2. Navigate per word (i.e. small chunks of data):

    alt+arrow keys : moves by word (left/right). Hold shift to select.

So to achieve your "expected result" you should press the right arrow first to get it to the end of your current selection and then cmd+shift+ to select the line leading up to it.

When you already have a selection:

  1. using the alt key combo's above will increase/decrease the selection based on direction (always modifying the end-point of your previous selection, presuming that you've missed the end point slightly). Same goes for adding single characters with shift+arrow keys only.
  2. the cmd combo's increase in both directions, presuming you're after selecting big chunks of text anyway.

Update

Long story short: what you want isn't really possible. If you look at the list of available system key bindings by running

plutil -convert xml1 /System/Library/Frameworks/AppKit.framework/Resources/StandardKeyBinding.dict -o -|pl|grep -v noop:|ruby -pe '$_.gsub!(/[^ -~\n]/)' | grep -i selection

You'll see that even though you can bind custom keys to all selection functions ~/Library/KeyBindings/DefaultKeyBinding.dict there is no such function that achieves your requested behaviour (since this behaviour is not built into the system).