How do i remap G to do what G and zz do simultaneously ? In other words, I would like to move to the bottom of the page and then have the text moved to the middle of the screen.

I tried something like :

nnoremap G :norm Gzz<CR>

But Im getting the error : command too recursive

  • 1
    You need :norm! to make it non-recursive. See :help :norm for more details. You can also just simply use nnoremap G Gzz, no?
    – filbranden
    Oct 6 '20 at 14:59
  • 2
    Yeah, just gonna say the same thing. nnoremap (and nmap) are for specifying Normal mode key maps. That means they accept Normal mode commands without having to use :norm[!].
    – B Layer
    Oct 6 '20 at 15:01
  • 1
    Welcome to Vi and Vim! Hopefully filbranden/B Layer will post an answer; if not, I will CW one.
    – D. Ben Knoble
    Oct 6 '20 at 18:17
  • I don't think I can claim any first rights to answer this one but if I could I relinquish them...will be away for a while. :)
    – B Layer
    Oct 6 '20 at 21:25
  • 1
    @BLayer enjoy the time :)
    – D. Ben Knoble
    Oct 11 '20 at 13:12

It is as simple as

nnoremap G Gzz

No need to go into ex-mode. You want to bind G to do what Gzz would do originally.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.