Monday 2 July 2007

Insert line numbers in Vim Search/replace

Just enter the following command in Vim, to replace all XXX match with the number of the line where the match is:

:%s/XXX/\=line(".")

Ex:

this is a example : XXX
and XXX


... is then

this is a example : 1
and 2