Having a file with two feilds which is :(colon) delimited as shown below:


I need to convert the :(colon) using vim editor which is in brackets [] to ! as shown below :


I tried this but I am not getting the output as shown above.


You could use:


\(\d\+\) Find a decimal number

\@<= Apply a positive look-behind. A positive look-behind means that the previous pattern ( in this case the one above ) is required to match on the next symbol. You can read more how VIM implements this here.

: Match on ':'.


You can use


See that we have grouped the elements [number1 and number2] with \([[0-9]\+\) and \([0-9]\+]\) and reproduced the first with \1 and the second with \2, putting a ! in between them.

I have used [0-9]\+ to indicate one or more digits, but you could simplify to [0-9]* (which means zero or more digits) if you are sure that there is always a number between the colon and each bracket:

  • Thank you so much its working
    – Kavitha
    Jun 15 '20 at 19:37

\v Enable extra regex features

(\[[0-9]+) capture group for opening bracket and at least one digit

: the colon you don’t want

([0-9]+\]) capture group for at least one digit and closing bracket

\1!\2 contents of the two capture groups with the bang you want between

  • thanks its working.
    – Kavitha
    Jun 15 '20 at 19:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.