Go to the last row, but stay in the same column

In Vim, you can go to the last line with G (or the first line with gg ), but this movement also goes to the first non-spatial character.

Is there a binding to go to the first row (or last, respectively), but stay in the same column?

+7
source share
2 answers

This will be set nostartofline . In this case, gg and G will contain columns, if possible, 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.). [..] 
+12
source

Yes, there is a key binding for this. But this is all right.

  • 1 CTRL+End : first row, same column
  • CTRL+End : last row, same column
0
source

All Articles