I am using vim and I think I know how to change all of the / to ) but I do not know how to apply it for only lines that end in )
I want to change this:
apples/oranges/grapes)
apples/oranges/grapes
apples/oranges/grapes)
apples/oranges/grapes
to this:
apples)oranges)grapes)
apples/oranges/grapes
apples)oranges)grapes)
apples/oranges/grapes
The vim
solution is very similar to the sed
solution:
:g/)$/s!/!)!gEnter
I’m assuming that you want to edit only the lines where the last character is )
. If you want to include lines where )
is the last non-blank character, use
:g/)\s*$/s!/!)!gEnterwhere
\s
is code for a space character (space or tab). I'm using !
the way Hauke Laging uses +
; that’s just a matter of personal preference.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments