Mark the location where the vanity will be installed by snapping a chalk line on the wall to mark each side of the vanity. This allows you to properly position the lighting.
Locate a stud in the wall between the chalk lines that is as close to being centered between the chalk lines as possible.
Hold a circular electrical box against the wall next to the stud, and trace the box onto the wall.
Cut a hole in the wall for the electrical box with a drywall saw.
Using a stud finder, locate a stud in the wall where you want to install the light switch. Trace an old-work electrical box onto the wall, and cut a hole with the drywall saw.
Feed a 12/2 electrical cable between the hole in the wall for the light switch and your home's main electrical box, and a second cable between the light switch hole and the hole for the vanity light. A 12/2 cable has two insulated 12-gauge wires and a bare ground wire. Do not connect the cable to the main box.
Punch out the knockout hole on the back of the circular electrical box (for the vanity), and slide the cable through it. Insert the box into the wall, and screw it to the stud.
Punch out the knockout holes in the old-work box (for the light switch), and slide both electrical cables through them. Insert the box into the hole in the wall, and screw it to the wall.
Strip about 4 inches of sheathing from the cable, and 1 inch of insulation from the black and white wires in the cable with wire strippers.
Cut a 3-inch-long piece of copper ground wire out of leftover 12/2 cable.
Bend the ends of the white and black wires into hooks with a pair of pliers. Loosen the terminal screws on the sides of the light switch, and hook the black wires onto the brass-colored screws and tighten them, then connect the white wires to the silver-colored screws.
Screw one end of the 3-inch ground wire to the ground screw at the bottom of the light switch, and connect the other end to the ground wires from the cables by twisting them together with a plastic connector cap.
Slide the wiring into the box on the wall, and screw the switch to the box with the mounting screws. Place the plate cover onto the wall over the switch.
Connect the wiring to the light fixture. Follow the manufacturer's instructions for the fixture you purchased, but the general installation procedure involves attaching the black wire to a brass-colored screw on the fixture, the white wire to a silver-colored screw and the bare ground wire to a ground screw or green ground wire on the fixture.
Slide the wiring into the electrical box, and mount the fixture onto the wall, following the manufacturer's instructions.
Install the lightbulbs for the fixture, and hire an electrician to connect the cable to your main electrical box. Most building codes require that a certified professional complete the connection due to safety issues.