It looks like you've used a visual blockwise selection; when pasting that, no new lines are created, but instead the contents are inserted (at the cursor position) inside the existing lines. (That also explains your second issue, the remaining empty lines.)
If you want to move lines, be sure to start linewise selection with Shift + V; you'll see a -- VISUAL LINE --
indication in the status line at the bottom. In your example, that would be (with the cursor anywhere on the printf("First line...
part) Vjjd
. Of course, with such small amount of lines, it's easier to skip visual selection and use a count: 3dd
.
And beyond
Once you have the basics right (did you try vimtutor
, also look at the excellent built-in :help
, or the plethora of Vim tutorials on the web, especially http://vimcasts.org/), there are several ways to improve on this workflow: text objects, plugins that can select function bodys or indented lines, etc.