Vim: Function copy

vim

Solution

This is what I do in JavaScript and PHP:

va{Vy

- Place the cursor somewhere in my method,

- `va{` to visually select the the code block,

- `V` to turn the selection from character-wise to line-wise,

- `y` to yank

If you are too deep and `va{` only selects a portion of your function you can do more `a{` until you select what you want.

Problem

Is there a command to copy a complete function? (Not by selecting through mouse) ex: `10yy` --> will copy `10` lines from the cursor position. I do not know the no of lines of a function, but want to copy the entire function. Is there any command to copy the entire function?

Original source