How to find/replace in files using keyboard in vscode

Viewed 1183

I'd like to use the keyboard to

  1. Open the Find/Replace In Files sidebar
  2. enter my find & replace text
  3. run the find & replace
  4. step through each of the found values and choose to either
  5. replace current result and skip to next, or
  6. skip to next

I've looked at the keyboard shortcuts and can't find how to do 3, 4 & 5 easily. In lots of editors (e.g. VS) there's a 'Find Next' and a 'Replace Next' button, but not in vscode?

1 Answers

Here's the best I could find. It doesn't feel as smooth as Find/Replace Next (i.e. steps 5 & 6) so I'd love to hear anything better:

  1. Ctrl+Shift+H to open the Find/Replace In Files sidebar
  2. type search text, TAB or Ctrl+Down to next field, type replace text. See button tooltips for their shortcuts, e.g. Match Case.
  3. ENTER to run the search
  4. Use Ctrl+Down a few times to get to search results, then Up/Down to move between results
  5. Press Ctrl+Shift+1 to Replace current result & move to next -- BUT ONLY if the Search Sidebar has focus. If Editor has focus, first press Ctrl+0 to focus the Search Sidebar again.
  6. Up/Down arrows to go to a different result in the sidebar. You can press F4 and Shift+F4 to go to next/prev result without replacing, but note this puts focus on the Editor. F4 still works from the Editor for Next Result, but you need to focus the sidebar if you want to Replace Next.

Ctrl+Alt+Enter if you want to Replace All.

I can't see a keyboard shortcut for 'Dismiss' a search result. i.e. with the mouse you can click on the X to the right of each result to Dismiss it from the list.

Related