Can send AT+ commands, but can't upload sketch to ESP8266 via Arduino Uno
You mention:


  connecting GPIO0 and GPIO2 to to Vcc or ground


I've had success with this sequence:


GPIO0 to gnd (and hold momentarily)
RST to gnd (then let go, while holding GPIO0 to gnd)
let go of GPIO0 from gnd (e.g. let it float again)


To do a firmware flashing, you need to hold GPIO0 to ground for the duration of the flashing process, so the sequence would be slightly different.

You can do this just prior to "build and upload" in the Arduino IDE—provided the build process doesn't take too long.  It will sometimes still fail, in which case reset the ESP8266 (RST to gnd momentarily) and restart the sequence. 

I've found a little test/development harness (like this one http://www.buildcircuit.com.au/esp8266-test-board) is very handy for doing this repeatedly.