Sort selected text from Visual Studio context menu

VS 2019 & VS 2022:

  1. Select lines. The last selected line is where the cursor is – the line is taken into account even if it is empty and there is no visible selection.
  2. Shift + Alt + L, Shift + Alt + S => Ascending sort.
  3. Shift + Alt + L, Shift + Alt + S (same selection same keys) => Descending sort.

The command can also be invoked from menu (@sharpener): Edit | Advanced | Sort Lines

This shortcut applies to the most used scheme: the Visual C++ 6 keyboard mapping scheme (and possibly other schemes). You can check your scheme in Options | Keyboard | Apply the following additional keyboard mapping scheme:.

You can check the shortcut in Options | Keyboard | Show commands containing: Edit.SortLines | Shortcuts for the selected command:.

Leave a Comment