Saturday, September 04, 2021

Re: vi: count occurrences of a substring

> Date: Sat, 4 Sep 2021 23:22:29 +0100
> From: ropers <ropers@gmail.com>

> It's still a little disconcerting to me how getting sed to play nice
> with \n *from inside vi* still seems like a bridge too far

easy peasy. to sed all spaces into newlines from nvi, enter

:!sed 's/ /&^V^M/g;y/^V^M/\n/'

echoed as

:!sed 's/ /&^M/g;y/^M/\n/'

but then it begs the question, why not open a new buffer and

:1,$s/ /^V^M/g

echoed as

:1,$s/ /^M/g

No comments:

Post a Comment