Search for exact solutions to the generalized nonlinear Schrödinger equation is one of the essential directions in studies of the nonlinear dynamics in optical soliton and Bose-Einstein condensates. Stable soliton modes are of great significance for the experimental realization and potential application. In this paper, based on the introduction of a similarity transformation, the variable-coefficient nonlinear Schrödinger equation is transformed into the nonlinear Schrödinger equation, and then the single soliton solution, two-soliton solution and soliton solution in continuous-wave background for the variable coefficient nonlinear Schrödinger equation are obtained by using the known solutions. Meanwhile, their image analysis and relative discussion are given by selecting the different parameters in detail.