Moving the the very bottom of the file with vi

6

3

No, I'm not talking about vim, I'm talking about old-school vi; because in vim you can actually issue a :bot and it'll move to the bottom of the file.

leeand00

Posted 2010-04-13T22:10:13.117

Reputation: 14 882

Answers

14

From command mode, type the upper case letter 'G'.

Marnix A. van Ammers

Posted 2010-04-13T22:10:13.117

Reputation: 1 978

What about going back to the top of the file? – Josh K – 2010-04-13T22:32:10.780

2Prefix the G with a line number: 1G – coneslayer – 2010-04-13T22:35:20.333

1Alternatively :gg will bring you to the top – akid – 2010-04-13T23:34:21.440

1Or :1 to jump specifically to line one. – bpanulla – 2011-07-29T15:12:28.650

3

Esc+Shift+Colon to get to the : prompt.

Then type any integer and ENTER to jump to that line number or...

$ to jump to the end line of the file.

Other uses of the $ in vi are:

E.g.

:1,$s/foo/bar/

this means: take the range of lines from 1 to the end of the file ($) and search them (s) for 'foo' and replace them with 'bar'.

I learned vi back in 1989 and I still use it today!

JethroSquid

Posted 2010-04-13T22:10:13.117

Reputation: 66

This one makes more sense to me, because $ is the end of the line too. – leeand00 – 2013-12-30T13:08:56.460