There are a few direct trains that leave from large stations in Tokyo to Yokohama.
From Shinjuku Station, you can take the JR Shonan-Shinjuku Line to Yokohama station (33 mins, ¥570). You can also take the Fukutoshin Metro line (41 mins, ¥450).
From Tokyo Station, you can take the JR Tokaido Line (25 mins, ¥480), JR Yokosuka Line (30 mins, ¥480), or the Keihintohoku Line (39 mins, ¥480).
Although you’ll mostly be walking for this Yokohama Day Trip from Tokyo Itinerary, the Minatomirai Line or JR Negishi Line are the most common to get around Yokohama.