Suppose you have 5 open tabs in order from 1-5. If you select tab 1, then select tab 5 and close it (ctrl+w), the editor goes back to tab 1.

I want it to go to tab 4, i.e. the previous neighboring tab of the tab that was closed. Not the previously selected tab.

Is there a setting in VS Code for this behavior?

2 Answers 2



In settings.json:

"workbench.editor.focusRecentEditorAfterClose": false,

It opens the tab to the right.


This question is duplicate with: https://stackoverflow.com/questions/62230903/how-to-get-visual-studio-code-to-select-the-correct-tab-when-closing-the-current

Answer can be found there. In short: vscode doesn't offer this functionality. You need to use a macro extension like multi-command.

  • Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
    – Community Bot
    Jan 13, 2023 at 15:07
  • 1
    Better said, that question is a duplicate of this one. Jan 13, 2023 at 20:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .