0

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

6
  • 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
    Commented Oct 6, 2020 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
    Commented Oct 6, 2020 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
    Commented Oct 6, 2020 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
    Commented Oct 6, 2020 at 21:25
  • 1
    @BLayer enjoy the time :)
    – D. Ben Knoble
    Commented Oct 11, 2020 at 13:12

1 Answer 1

3

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 and acknowledge you have read our privacy policy.

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