2

There are already several questions about "how do I switch back and forth between code and the terminal in VS Code", and the (correct) answer to all of them is:

ctrl + `

But there's a problem with that answer. I very often switch to the terminal and hit up + ENTER to run the previous command. However, when I do so too quickly, VS Code focuses me not on the terminal, but on the terminal-switching-dropdown in the upper right corner.

As a result, I wind up changing terminals (because the up + ENTER goes into the dropdown and not the terminal itself) ... when I just want to focus the existing terminal and type there.

Is there any way to make VS code not focus on that dropdown? Or even just to remove it entirely?

machineghost
  • 33,529
  • 30
  • 159
  • 234
  • Tried to do this on my system (version 1.43.1, running on Ubuntu) but does not happen for me at all, however fast I try to do `ctrl + \` + up`. I assume you already checked that this key sequence has not been bound to anything in your system? – Mahathi Vempati Mar 20 '20 at 18:12
  • I checked and `ctrl + \` + up` and don't have it mapped. I also just tried doing it now, and ... it doesn't do it for me ATM either. Under some conditions (maybe when the editor is busy doing other things?) it focuses the dropdown instead of the terminal itself, but I'm not sure exactly what those conditions are (I always hit them by accident). – machineghost Mar 20 '20 at 18:15
  • yeah, possibly. I used a backslash before the tilde to format it. – Mahathi Vempati Mar 20 '20 at 18:19
  • 1
    Thanks (fixed my comment). I'll try to suss out those conditions and report back, but maybe someone else familiar with this issue will respond in the meantime. – machineghost Mar 20 '20 at 18:20
  • You don't need to switch focus to the terminal to re-run your last command. You can do it from anywhere with the answer: https://stackoverflow.com/questions/55336497/make-a-keybinding-to-run-previous-or-last-shell-commands focus would stay in your editor and run the last command. If you want something else, that answer could probably be modified to re-run the last command and then switch focus to the terminal. – Mark Mar 20 '20 at 19:06
  • It actually seems like just pressing `CTRL +\`` (without even pressing "up") opens up a new bash shell instead of going into the existing terminal ... but I have yet to determine **why** it only rarely does that, but usually sends me into the normal (existing) terminal. Why VS Code, why?!?! – machineghost Mar 21 '20 at 01:38

1 Answers1

1

It turned out the problem wasn't the up key, it was the SHIFT key. In VS Code CTRL + tilde sends you to the terminal, but CTRL + SHIFT + ` instead opens a new terminal session.

(As a side note, I could use the "code" tag to express that second tilde, but Stack Overflow botches both tildes and the "code" tag when I try to format just "CTRL + tilde".)

The shift key on my keyboard sticks sometimes, and it was making this happen without me realizing it (and I mistakenly attributed it to the up key since I press both together).

Thanks to everyone who helped me narrow the problem down in the comments!

machineghost
  • 33,529
  • 30
  • 159
  • 234