I need to replace multiple lines using vi. For example,
any numbers_Apple to
0001_Apple 0010_Apple 1021_Apple … 8383_Apple
Vi and Vim Stack Exchange is a question and answer site for people using the vi and Vim families of text editors. It only takes a minute to sign up.Sign up to join this community
"Search and replace" and "regex" (regular expressions) are how you achieve this kind of task. Websearching those terms will yield lots of information.
Vim's search and replace functionality is done from "normal" mode by typing
: and then the search replace pattern, like
:%s/searchforthis/replacewiththat/g (it's similar to
sed in the Linux command line environment).
So for your case you can do
:%s/[0-9]*_//g to simply delete the part of the pattern you don't want... unless that deletes too much, then you could enhance... like