Vi Insert Text for Specific Line Ranges

Vi Insert Text for Specific Line Ranges

Seeking help in vi editor.

I want to insert in the begin of line. I wanted it to be insserted for specific line ranges. for eg, line number 1 to line number 20.

Any idea

1 Answer

Try this:

:1,20s/^/#/

where 1 and 20 compose the line number range, and the # is the text to be inserted at the beginning of the line.

That's the simplest way to do it, but there's a whole thread on other things to try at

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Sarah Jenkins
Author

Sarah Jenkins

Sarah Jenkins is a veteran tech journalist with over 12 years of experience covering artificial intelligence, mobile innovations, and digital ethics. Her insights have appeared in leading technology publications worldwide.