I am trying to write a command along the lines of the following:
vim -c "XXXXXX" myFile
Instead of the "XXXXX" I want to supply some commands to vim to add some text to an arbitrary point in the file, both by specifying an exact line number and, in a different scenario, by searching for a specific line and then insert on the line above.
What I am trying to do is a sort of clever "append" where I can append lines to a code block or function inside a script. Ultimately I am aiming to have a setup script which will go and alter maybe a dozen system files.
Ideally it would only involve one -c flag and ideally it would be readable to anyone that can understand normal mode commands - in my head I was originally thinking something like "ggjjjiInsertingOnLine4:wq" once I can get it into normal mode.
sedorawkmight not be more suited for this task. Vim was designed for interactive use in contrast tosedandawk. Nonetheless, this can surely be accomplished with vim. – Marco Oct 15 '14 at 20:02vim +33G +r/path/to/somefile +wq /path/to/fileto insert the contents ofsomefileat line 33 offile? – DopeGhoti Oct 15 '14 at 20:06