Vi: insert at the beginning of the file

One thing that bothered me with vi is that paste (p) inserts lines after the line I'm on, making it impossible to paste things at the top of the file.

For example, say that I go through and add a UTF-8 declaration to the beginning of several files:

# -*- coding: utf-8 -*-

      

yy and he yanked. Good.

I navigate to another file, gg to get to the top, and p to insert, and I get something like this:

import sys
# -*- coding: utf-8 -*-

      

what I do not want.

Now I always find new things I can do with vi, so I figured this is what I should have done, but just didn't know how. However, the search does not give very useful results, since everyone and their mother have a vi (m) cyber table, with both p and gg in it. So I come to SO: Is this possible, and if so, how?

+2


source to share


1 answer


P

(capital) inserts above / before as P

(lower case) inserts below / after.

o

and o

are similar. o

inserts the line after the current one, and o

inserts. I use these commands a lot.



You can go to the beginning of the file using the [[

, 1G

, gg

or :1<CR>

.

+22


source







All Articles