visual-studio-codevscode-keybinding

Toggle selection endpoints


How can I toggle the cursor position in VS Code — from the start to the end of a selection (and vice versa)?

I'm looking for functionality similar to pressing o in Vim's visual mode, which swaps the cursor between the beginning and the end of the selected text.


Solution

  • I have written an extension: Select By

    It exports the command: selectby.swapActive

    In the Command Palette: Swap the anchor and active (cursor) position of the selection(s)

    Maybe better to make a keybinding for the command if you use it a lot.

      {
        "key": "ctrl+k ctrl+s",
        "when": "editorTextFocus",
        "command": "selectby.swapActive"
      }
    

    You can choose any key combo you like.