I'm working with the vim editor and I found y,yw respectively to copy a line and a word but how can I do the following task in vim?


From this line how can I copy and paste ack.goo using vim editor?


Move cursor under a, press v, use arrow key to select until o, press y. Then move cursor to where you want to paste the text, press p. Done.

| improve this answer | |
  • 5
    Try vimtutor as your first step learning vim (: – Daniel Le Aug 4 '11 at 15:25
  • ye I'm gonna refer that soon. – Vishwanath Dalvi Aug 4 '11 at 15:27
  • 1
    Why not do this?0fay2fo.Though visual selection is better if you don't wanna count,but always rely on f<character> – bollovan Aug 6 '11 at 16:45
  • arrrrows are evil! :) – takeshin Aug 11 '11 at 9:13

y is followed by a movement, so, like you said, yw will copy a word because w is the movement that takes you forward one word.

You can also type a number before an action or before a movement (or both, I suppose, but that multiplies the numbers and that just seems silly) to repeat the action/movement that many times, so to yank 5 words you can type 5yw or y5w.

In your example, l moves the cursor left, so if the cursor is on the "a" you want, you can do y7l or 7yl.

| improve this answer | |
  • Us vi oldtimers are always counting chars, words or lines because we often use things like y7l, c3w or d5d. – Michael Dillon Aug 11 '11 at 5:18

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.