Open a File Directly at the Requested Line with Vi

When you compile a program and an error occur, the compiler will report the file name and line number with the error.

Usually, I use vi to access the file, then type “:line_num”, for example if I want to jump to line 123, I would type :123 after opening the file.

But there is a way to do that directly with vi by using +line_num. For example:

 vi +123 code.c

To go to the last line, I would normally use the capital letter G when vi is started, but this can be done while opening the file as follows:

vi +$ code.c

One last tip: To go back at the top of the file in vi, simply use :0 or the capital letter H.

Share this:
FacebookTwitterHacker NewsSlashdotRedditLinkedInPinterestFlipboardMeWeLineEmailShare

Support CNX Software! Donate via cryptocurrencies, become a Patron on Patreon, or purchase goods on Amazon or Aliexpress

ROCK Pi 4C Plus

Leave a Reply

Your email address will not be published. Required fields are marked *

Khadas VIM4 SBC
Khadas VIM4 SBC