7

Can anyone suggest , how to jump the line in vi editor ? Once I open any file using vi editor and I have such a line :

printf("jfdkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkjghjthrttttttttttttttttttttttttttttttujhrjghjrhjghrtjhgjhtrjhgjhjjrjwhjghjrhghrhgjhrjghjrhhhhhhhgjkrhgjrhjgrhg");

so what to do if I want to directly go to the end of the line or jump the line . For now I have to travel whole the line . Can anyone help me ?

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)

6

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
  • 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 – Sergiy Kolodyazhnyy Nov 23 '16 at 19:43
1

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.