Bereshit / Genesis 26:18 · Pshat
וַיָּשָׁב יִצְחָק וַיַּחְפֹּר אֶת־בְּאֵרֹת הַמַּיִם אֲשֶׁר חָפְרוּ בִּימֵי אַבְרָהָם אָבִיו וַיְסַתְּמוּם פְּלִשְׁתִּים אַחֲרֵי מוֹת אַבְרָהָם וַיִּקְרָא לָהֶן שֵׁמוֹת כַּשֵּׁמֹת אֲשֶׁר־קָרָא לָהֶן אָבִיו׃
And Yitzchak dug again the wells of water that had been dug in the days of Avraham his father, which the Philistines had stopped up after Avraham's death. And he gave them the same names his father had given them.
Pshat פְּשָׁט
The same names
Sometimes you inherit your parents' work, abandoned and filled in. You can start your own, or you can dig out what was there. Yitzchak digs out his father's wells and gives them their old names, and Rashi and the Netziv explain when and why.
Rashi specifies the time: these are the wells dug back in Avraham's days, which the Philistines filled in, and Yitzchak (Isaac) dug them out again, even before he left Gerar. The Netziv sees a benefit of exile here: living now by the valley itself, Yitzchak watched over the wells himself, and the locals could no longer do wrong, because he complained to the king. Hence a lesson: what seems evil to us often turns to good in time. And he gave the wells their old names so that no one could contest them: they had been held since Avraham's days.
How Rashi and Haamek Davar explain it
Rashi And he dug again
The wells that had been dug in the days of Avraham his father, which the Philistines had stopped up, he dug again even before Yitzchak left Gerar.
Haamek Davar And Yitzchak dug again and so on
For living himself in the valley, by the field, he saw the wells and watched over them, and the people of the fields could no longer do wrong, since he complained to the king about those who stopped them up, and the king had no choice but to do justice. From this we learn about the way of exile: the Holy One, blessed is He, overturns plans, and what seems to us as though we are being harmed many times turns to good after a while, as will yet come.
And he gave them names and so on.
So that they could not be contested, since he had already held them in Avraham's days without any dispute.
Takeaway
The order of events: Avimelech told Yitzchak to leave, Yitzchak settled in the valley of Gerar (Bereshit / Genesis 26:16–17), and only then does the verse tell of the wells. Rashi reads "dug again" as something done earlier, while Yitzchak still lived in Gerar itself.
Rashbam explains the old names as the Netziv does: so that no one could contest the wells (Rashbam 26:18). Bekhor Shor adds: had he changed the names, people would have said these were not his father's wells (Bekhor Shor 26:18).
The Netziv writes "the way of exile": Yitzchak in Gerar is for him an image of the people in exile, where even being driven from a city turns into protection.