Although he learnt Confucianism and Japanese classical literature at a domain school, Meirindo school, after Haihan-chiken (abolition of feudal domains and establishment of prefectures), he moved to Sobue-mura, the ancestral land of the Yokoi family, where he entered the higher normal course at Aichi prefectural training school and graduated in 1876.
藩校明倫堂で儒学・国学を学ぶが、廃藩置県後に横井氏代々の地である祖父江村に移り住み、愛知県が建てた養成学校上等師範科に移って明治9年（1876年）に卒業する。