Second seed Federer, who received a first-round bye, broke Ramos-Vinolas twice in the opening set and sailed through his service games without facing a break point in the match.
Ramos-Vinolas, who upset Federer four years ago to snap a 15-match losing streak against top-10 players, recovered well to force a second-set tiebreak but his Swiss opponent came back from 4-1 down to seal victory.
Laver Cup
'I don't think his hands are that good' - Zverev coaches Ruud mid-match
A DAY AGO
"I focused, because when you travel around the globe, you're missing a bit of energy. Those first few games or matches can be sometimes a bit tricky," Federer said.
"Serve was solid. I was hitting my spots and really was never in trouble there. But of course all of a sudden, being in a breaker, calls out for different play sometimes and different momentum.
"He had his chances, but it was a nice comeback for me, and overall."
Federer, a twice Shanghai champion, will next meet Belgium's David Goffin or Kazakh Mikhail Kukushkin for a place in the quarter-finals.
Former world number one Andy Murray showed some more positive signs in his injury comeback but eventually went down in a bruising battle with Italy's Fabio Fognini.
Murray twice served for the match in the deciding set, but Fognini dug deep to force a tiebreak and secure a 7-6(4) 2-6 7-6(2) win in just over three hours.
"There is a lot of things that I need to get better at, and I can do much better," said Murray, who underwent a career-saving hip resurfacing procedure in January.
"I will go away and I'll work on those things and be in a better position next time I play against him."
Laver Cup
'It's special, awesome to see' - Laver and Federer get standing ovations at Laver Cup
A DAY AGO
Laver Cup
'Huge cheer straight away' - Federer gets standing ovation at Laver Cup
YESTERDAY AT 18:02