Removing trim around the windows is tricky - you can buy a trim removal tool or can make one like I did from a putty knife - you cannot remove it without one of these tools or you will damage the trim. To remove the trim, you have to slide the trim tool underneath the trim - you're coming it with the tool flat on the glass, and slide it under the trim. Then slide the tool along underneath the trim until you hit one of the clips. To release the trim from the clip, you have to catch the clip with the spike end of the trim tool, and pull it outwards. This pulls the clip in the direction you're pulling the tool, and releases the trim from the clip. Sometimes you have to come at the same clip from both sides.
In order to do it without damaging the trim, I went to a junk yard and ripped a couple of pieces of the trim off to see exactly how it was held on and how many clips there were and where they were located.
Installing the trim after you have painted it, is simply a matter of pushing it on, and it snaps into place - make sure you have it lined up right, because you can't slide it once it clips in, and then you will have to try to remove it without damaging your nice new paint job.