Notes // Keyboard Shortcut for Selecting Next and Previous Occurrences in Visual Studio Code

The keymap command names for selecting the next and previous occurrences in Visual Studio Code.

I have been using Visual Studio Code for a few months now and I love it. I have been integrating many of the IDE features into my old-school emacs workflow. For some reason my "Selection >> Add Next/Previous Occurrence" wasn't bound to a keyboard shortcut. I couldn't find any mention of "occurrence" in the default keymap file. After a bit of digging I uncovered the command names.

The commands are:

  • Selection >> Add Next Occurrence
    • editor.action.addSelectionToNextFindMatch
  • Selection >> Add Previous Occurrence
    • editor.action.addSelectionToPreviousFindMatch.

Here is the snippet from my keybindings.json:

// Selection >> Add Next Occurrence 
{   
    "key": "ctrl+alt+n",            
    "command": "editor.action.addSelectionToNextFindMatch",
    "when": "editorFocus" 
},
// Selection >> Add Previous Occurrence
{   
    "key": "ctrl+alt+p",            
    "command": "editor.action.addSelectionToPreviousFindMatch",
    "when": "editorFocus" 
}
Written by
Published
Email destin{AT}destinmoulton.com if you have any comments or questions.