Jump to some specific line in the vi editor
Solution 1
You can find the line by searching for some unique part of it with /
Press esc and type:
/printf
and the cursor will jump to the first instance of printf
. press n
to go to the next match until you reach the line you want. To move to the end in normal mode, type
$
To jump to the end and change to insert mode, type:
A
(shift+A)
Solution 2
You can also press the end key which will put the cursor to the end of the line.
To go to a specific line like line 44 press esc then
:44
Solution 3
Here are some basic vim commands which will help you accomplish some of the basic tasks. Try this in normal mode not in insert mode.
e Move to the end of a word.
w Move forward to the beginning of a word.
3w Move forward three words.
W Move forward a WORD (any non-whitespace characters).
b Move backward to the beginning of a word.
3b Move backward three words.
$ Move to the end of the line.
0 Move to the beginning of the line.
If you are new to vim I recommend you to complete the vimtutor. From terminal type vimtutor . Finish it so that you will be confident in editng using vim.
Related videos on Youtube
Avani badheka
Updated on September 18, 2022Comments
-
Avani badheka over 1 year
How can I jump the line in the vi editor? Once I open any file using the vi editor and I have such a line:
printf("jfdkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkjghjthrttttttttttttttttttttttttttttttujhrjghjrhjghrtjhgjhtrjhgjhjjrjwhjghjrhghrhgjhrjghjrhhhhhhhgjkrhgjrhjgrhg");
So what should I do if I want to directly go to the end of the line or jump the line? For now I have to travel the whole line. How can I do it?
-
Avani badheka over 7 yearshelpful , upvoted
-
Sergiy Kolodyazhnyy over 7 yearsOr in command mode just type 44zt to jump to line and position the line on top of the screen. I use this a lot lately