Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jump to last line, but stay in the same column [duplicate]

In Vim, it is possible to jump to the last line with G (or the first line with gg), but that movement also jumps to the first non-space character.

Is there a keybinding to jump to the first line (or the last respectively), but stay in the same column?

like image 484
radlan Avatar asked May 25 '13 09:05

radlan


2 Answers

That would be set nostartofline. With it, gg and G will keep the column if possible just like j etc.

From :h startofline:

                           'startofline' 'sol' 'nostartofline' 'nosol'
'startofline' 'sol'     boolean (default on)
                        global
                        {not in Vi}
        When "on" the commands listed below move the cursor to the first
        non-blank of the line.  When off the cursor is kept in the same column
        (if possible).  This applies to the commands: CTRL-D, CTRL-U, CTRL-B,
        CTRL-F, "G", "H", "M", "L", gg, and to the commands "d", "<<" and ">>"
        with a linewise operator, with "%" with a count and to buffer changing
        commands (CTRL-^, :bnext, :bNext, etc.).  [..]
like image 200
timss Avatar answered Sep 21 '22 19:09

timss


Yes, there is a key-binding for that. But it's pretty out of the way.

  • 1 CTRL+End: first line, same column
  • CTRL+End: last line, same column
like image 24
doubleDown Avatar answered Sep 20 '22 19:09

doubleDown