M BUZZ CRAZE NEWS
// general

Jump to some specific line in the vi editor

By David Jones

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

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

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

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

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

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