This paper deals with improvements of the Trudinger–Moser inequality related to the operator QV(u):=−Δnu+V(x)|u|n−2u, where n≥2 and the potential V:Rn→R belongs to a class of nonnegative and continuous functions. Precisely, under suitable assumptions on V we consider the subspace E:={u∈W1,n(Rn):∫RnV(x)|u|ndx<∞} endowed with the norm ‖u‖:=[∫Rn(|∇u|n+V(x)|u|n)dx]1/n and we prove that if (uk) is a sequence in E such that ‖uk‖=1, uk⇀u≢0 in E and 0<p<pn(u):=βn(1−‖u‖n)−1/(n−1), then(⁎)supk∫RnΨ(p|uk|n/(n−1))dx<∞, where Ψ(t):=et−∑i=0n−2tii!, βn:=nωn−11/(n−1) and ωn−1 is the measure of the unit sphere in Rn. Furthermore, pn(u) is sharp in the sense that there exists a sequence (uk)⊂E satisfying ‖uk‖=1 and uk⇀u≢0 in E such that the supremum (⁎) is infinite for p≥pn(u). As an application of the previous result we prove the following sharp form of the Trudinger–Moser inequality for the subspace E. Consideringℓ(α):=sup{u∈E:‖u‖=1}∫RnΨ∘να(u)dx, where να(u):=βn(1+α‖u‖nn)1/(n−1)|u|n/(n−1), assuming some conditions of symmetry on V it is established (1) for 0≤α<λ1(V) we have ℓ(α)<∞, (2) for α≥λ1(V), ℓ(α)=∞ and (3) moreover, we prove that for 0≤α<λ1(V), an extremal function for ℓ(α) exists. Here λ1(V) denotes the first eigenvalue of QV(u).