vim: add a SmartWrite() function to deal with :w, :x, :w!