VIM global multiple line search and replace maintaining indent -
i trying perform multiple line search , replace while retaining indent, leading space, in code working with. below text sample approximates situation. problem i'm having preserving white space. i'm hoping non-plugin, plain jane vim solution via :%s/ ......
vim 7.2 on windows 7 autoindent on expandtab on
starting with:
apples, banannas, cherries, plums peas, green beans, corn, squash apples, banannas, cherries, plums
i add "pears,", without double quotes , following "cherries," line in list. desired outcome is:
apples, banannas, cherries, pears, plums peas, green beans, corn, squash apples, banannas, cherries, pears, plums
trying :%s/cherries,/&\rpears,/g yields ...
apples, banannas, cherries, pears, plums peas, green beans, corn, squash apples, banannas, cherries, pears, plums
trying :%s/cherries,_s.\s*/&pears,\r/g yields ...
apples, banannas, cherries, pears, plums peas, green beans, corn, squash apples, banannas, cherries, pears, plums
thank you!
you take advantage of :g
, auto-indentation normal o
:
:g/cherries,/normal opears,
Comments
Post a Comment