I'm attempting to replace all strings in a text file surrounded by single quotes and ending with an @ first followed by any number and then any mix of any other letter(s) or #(s) like these:
'package@1.1.k'
'otherpackage@14'
'anotherpackage@7.8'
and I wish to select only the single quotes and remove them like so:
export MYVAR="/dir/'package@1.1.k':$MYVAR"
to:
export MYVAR="/dir/package@1.1.k:$MYVAR"
in the entire file. I figured out a way to remove the proceeding single quote and preceding single quote in two separate commands (using vim's zs
and ze
, similar to positive and negative lookarounds):
:%s/'.*@.[0-9]*.*\zs'//g
:%s/\zs'\ze.*@.[0-9]*.*//g
However, I am curious about doing it in a single operation as I want to learn more about using Neovim, and apply the answer to future operations.
I am actually using Neovim, if that comes with any additional features related to this.