We demonstrate an endoscope-compatible single-fiber-based device that performs simultaneous confocal microscopy and high-precision laser microsurgery. The method is based on mapping of two-dimensional sample coordinates onto the optical spectrum and allows us to perform two-dimensional imaging and microsurgery without any mechanical movement of the probe or the sample. The technology holds promise for creating highly miniaturized endoscopes for applications such as brain tumor, pediatric, and endovascular surgeries where high-precision, small, and flexible probes are required.