I'm trying to search for the string /c
in the entire file, and when it's found I'd like to delete everything - including the /c
itself - up until the next occurrence of /
(but not the /
itself). For the purposes I'm using this for, you can assume that:
- not every line will have a
/c
in it, - but when there is one in a line, it will always be the only one in that line, and
- there will always be a
/
following it at some point in that same line.
I've learned of macros recently, and I found that if I create a macro with qa/\/c<CR>dt/q
and then run it a large number of times with :g//normal 500@a
, that it will make all the desired deletions (until it gets to the end of the file when it gives the error E486: Pattern not found: \/c
). But I was wondering if there is a simpler way to do it - with some kind of :%s
search command - that requires only one line. I'm quite certain there is, I just don't know how to do it. Alternatively, if a command or function could be created in the _vimrc
file that would accomplish this task, that would work too.