número de ocurrencias de una palabra en una parte del archivo en vim

Suppose I would like to find the number of occurrences of the word 'asd' in a part of file, eg., from line 21 to line 234. How would I do that in VIM?

preguntado el 11 de junio de 12 a las 19:06

1 Respuestas

Try this for counting :21,234s/asd//gn

Editar

Since your vim is so old, try greping and count like

sed -n 21,234p filename | grep -o asd | wc -l

Respondido el 11 de junio de 12 a las 20:06

are you adding a / at the end? I've just tested and it is working, make sure you are copying it the exact way - eric fortis

I am not sure why but giving //gn in the end as mentioned is giving that error! I have tried :21,234s/asd/&/g or :21,234s/asd/asd/g and they are giving the correct count though the file will be shown as modified. I am using vim 6.3 version. - silentNinJa

cant help! its the version installed in my company servers!! thanks for the help :) - silentNinJa

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.