In Vim pressing G takes you to the last physical line. But, if the last line is wrapped around G puts the cursor on the first wrapped line in that last line, not the last wrapped line.

So, is there a way to get to the last wrapped line when pressing G without me having to press j or gj a bunch of times?

  • 3
    What about G$? What's it for anyway?
    – Antony
    Aug 1, 2016 at 19:45
  • That's the one I am thinking about too but that puts me at the end of the last line. But, I would like it to be at the beginning of the last line. Aug 1, 2016 at 19:50
  • 3
    Damn, I just realized there is g0 all along. I feel really stupid for not being able to put that together. Aug 1, 2016 at 19:52
  • Just add it as answer with explanation
    – SibiCoder
    Aug 2, 2016 at 1:16

1 Answer 1


There are a couple solutions.

  1. You could use G$g0, like it was suggested in the comments. For example

    nnoremap G G$g0
    xnoremap G G$g0

    You don't really need to provide an omap since G is a line based movement, not a character-based movement. Explanation: G Moves to the last line, and $ moves to the end of that line. Then g0 moves to the beginning of that visual line, e.g. the first column of the last wrap.

  2. This is admittedly a pretty strange solution, but you could use a recursive macro. This is essentially the same thing as hitting gj a bunch of times, except that it is only one keystroke and it happens faster. For example:

    nnoremap G :let @g='gj@q'<cr>@g
    xnoremap G :<C-u>let @g='gj@q'<cr>@g

    As a side note, this will not move you to the first column, but the same column. You could always add g0 to the end, e.g.

    nnoremap G :let @g='gj@q'<cr>@gg0
    xnoremap G :<C-u>let @g='gj@q'<cr>@gg0

I recommend going with the first option.

  • Yeah, thanks. I realized I could use g0 after I posting the question. The second one seems rather tricky. Why is it faster? Aug 2, 2016 at 21:09
  • @DurgaSwaroop Sorry, my wording could have been better. I meant it is faster than hitting gj a bunch of times.
    – DJMcMayhem
    Aug 2, 2016 at 21:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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