Remove the damaged section of trim from the doorway by prying it off with your hammer and prybar. Take off only the damaged side. Don't break it further while taking it out.
Knock the nails out of the damaged piece, using your hammer.
Lay the damaged piece on top of a new, longer piece of the same type of trim, leaving space beyond both ends of the old piece. Set it face-up on the new piece, with the long edges lined up. Mark with your pencil along the two ends of the old piece, onto the surface of the new piece (Note: If it's a side piece, one end will be straight across, while the other is angled; if it's the top piece, both ends will be angled).
Remove the old piece and set the new piece on your miter saw. Cut the piece at both lines, swiveling the miter saw as needed. Generally, the straight cutwill be at 90 degrees and the angled cut will be at 45 degrees.
Set the new piece in place along the edge of the doorway, in the same position where the old piece was. Make sure the mitered end is lined up correctly to form the corner. Secure the piece by shooting in trim nails every foot or so along both long edges.