Skip to main content
added 21 characters in body
Source Link
Edd
  • 141
  • 1
  • 1
  • 6

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, eitherboth by specifying an exact line number orand, 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.

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, either by specifying an exact line number or 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.

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.

deleted 11 characters in body
Source Link
Anthon
  • 81.4k
  • 42
  • 174
  • 228

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, either by specifying an exact line number or 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.

Many thanks

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, either by specifying an exact line number or 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.

Many thanks

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, either by specifying an exact line number or 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.

Source Link
Edd
  • 141
  • 1
  • 1
  • 6

How do I use vim on the command line to add text to the middle of a file?

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, either by specifying an exact line number or 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.

Many thanks