Cable splitters work well if set up properly, but are much more expensive than long cables.
Crimp connectors might work for shift cables, but as noted above may not be sufficiently fail-safe for brake cables. In either case, I'd replace the cable instead, even if it's an oddball cable such as for old Huret or Suntour X-Press.