8

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?

3 Answers 3

9

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)

0
7

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
1
  • Or 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 Nov 23, 2016 at 19:43
2

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.

1

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .