We demonstrate high fidelity entangling quantum gates within a chain of five trapped ion qubits by optimally shaping optical fields that couple to multiple collective modes of motion. We individually address qubits with segmented optical pulses to construct multipartite entangled states in a programmable way. This approach enables both high fidelity and fast quantum gates that can be scaled to larger qubit registers for quantum computation and simulation.