I would like to yank one character and paste it in the first position of the succession of lines. For example, I need to add a "#" in the front of 7 lines of a file.
Someone can help me?
It depends largely on what you're calling vi
. If it is really original-vi, then you could do this by
In original-vi, you could only affect a range of lines using ex mode.
The ex mode of vi
does accept a range, but the analogous command
:1,7P
would not put
a character, but attempt to do something with lines. Rather, using ex mode, you would do a substitute, e.g.,
:1,7s/^/X/
but there is no way for a register value (the character(s) which you yanked) to be used in the substitution.
Further reading:
Note: this answer works for VIM only, not for VI.
You can yank it in a column by:
Side note: you can also ask your Vi(m) questions on: vi.stackexchange.com