I was looking for ways to search and replace on even/odd numbered lines in vim and I came across some solution on google groups https://groups.google.com/g/comp.editors/c/xk9DMoszgq4.
To search and replace on odd numbered lines:
:g/^/s/foo/bar/|+t+|-d
To search and replace on even numbered lines:
:2,$g/^/s/foo/bar/g|+t+|-d
The solution works, but i couldnt understand on what it is doing. I know basics about using g to filter out lines for a pattern, then do search and replace on those lines. But I dont get it on what is the code post pipe |
is doing.
Can anyone help me understand it ? Also point to some documentation if there is any, on what pipe does and how to use it ?