Show previously used file tab when closing a file

Main problem: I often accidentally press cmd + t when i want to just replace content with cmd + R. This is frustrating since this opens the New file window. I always quickly press Cmd + W to close the window and get back to work, but this is not taking me back to my working file but instead switches to a (random?) file in my tabs.

So two problem here:

  1. Cmd + T is too close to a often used shortcut (Cmd + R).
  2. Cmd + W doesnt take you back to previously active tab