The two thousand amot that every person has from their place of rest is granted even without verbalization and without intent. Furthermore, we learned in the Mishnah (45a) that one who sat on the road and stood up and found himself near a city, and his intent was not for the city—he may enter; and there was an incident where Rabbi Tarfon entered without intent. Rashi explained: one who sat on the road to rest—because he was tired and did not know that he was within the techum of the city, and it grew dark for him there, and when he stood up he saw that he was near the city and within its techum, and when it grew dark for him—he did not intend for his place of rest to be in the city but rather in his place; nevertheless—he has the techum of the city. And so wrote the Rif, and this is his wording: "Since if he had known that the city was near he would not have acquired a place of rest except with the residents of the city—it is as if he acquired a place of rest with them, and he is permitted to enter the city with them, and he may walk through all of it and two thousand amot outside of it." Thus far his words. And his place of rest was established in error, and therefore he has the place of rest of the city (the Ri). And in the subsequent Mishnah it is explicitly stated that even if one was sleeping at the time of the acquisition of the place of rest—he acquires a place of rest and has two thousand amot in every direction, and this will be explained in the next siman with the help of Heaven, and so wrote the Tur and the Shulchan Aruch; and see in section 4.
אלפים אמה שיש לו לכל אדם ממקום שביתתו, הוא אפילו בלא אמירה ובלא כוונה. ויותר מזה שנינו במשנה, (מ"ה.) דמי שישב בדרך ועמד והרי הוא סמוך לעיר, ולא היתה כונתו להעיר - יכנס, ומעשה היה ונכנס רבי טרפון בלא מתכוין. ופירש רש"י, מי שישב בדרך לנוח - שהיה עיף ולא היה יודע שהוא בתחום העיר, וחשכה לו שם, וכשעמד ראה שהוא סמוך לעיר ובתחומה, וכשחשכה לו - לא נתכוין להיות שביתתו בעיר אלא במקומו, ומכל מקום - יש לו תחום העיר. וכן כתב הרי"ף וז"ל: "דכיון (דאילו) [דאלו] היה יודע שהעיר קרובה לא היה קונה שביתה אלא עם בני העיר - הרי הוא כמו שקנה שביתה עמהם, ומותר ליכנס עמהן לעיר, והולך את כולה וחוצה לה אלפים אמה" עכ"ל. ושביתתו בטעות היתה, ולכן יש לו שביתת העיר. (הרר"י) ובמשנה שאחריה מפורש, דאפילו היה ישן בעת קניית השביתה - קונה שביתה ויש לו אלפים אמה לכל רוח, וזה יתבאר בסימן הבא בס"ד, וכן כתב הטור והש"ע ועיין בסעיף ד'.