In vi editor how do I go to a particular line ?
For example if I open a file named file.py is there an option for open the file at a particular line or can I open my file and then go to line with keybord shortcut ?
In vi editor how do I go to a particular line ?
For example if I open a file named file.py is there an option for open the file at a particular line or can I open my file and then go to line with keybord shortcut ?
To make vi start at a particular line in a file, add +line_num to the command you use to start vi. Replace line_num with the line number, for example:
vi +14 file.py
You can also use the ex command line to go to a line. (For information about the ex mode, see Use the vi text editor) For instance, if you wanted to go to line 14, you could press Esc and then enter:
:14
There is also a vi command. The G jump (goto) motion takes an optional count prefix, which is the line number to go to. Hence 14G.
For the kbd addicts, that's
1, then 4, and then Shift+G.