In this paper, the variable-coefficient (1 + 1)-dimensional Benjamin-Bona-Mahony (BBM) and (2 + 1)-dimensional asymmetric Nizhnik-Novikov-Veselov (ANNV) equations are investigated via the generalized exponential rational function method (GERFM). This paper proceeds step-by-step with increasing detail about derivation processes, first illustrating the algorithms of the proposed method and then exploiting an even deeper connection between the derived solutions with the GERFM. As a result, versions of variable-coefficient exact solutions are formally generated. The presented solutions exhibit abundant physical phenomena. Particularly, upon choosing appropriate parameters, we demonstrate a variety of traveling waves in figures. Finally, the results indicate that free parameters can drastically influence the existence of solitary waves, their nature, profile, and stability. They are applicable to enrich the dynamical behavior of the (1 + 1) and (2 + 1)-dimensional nonlinear wave in fluids, plasma and others.