Vim Tips Wiki
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.
Tip 670 Printable Monobook Previous Next

created March 3, 2004 · complexity basic · author Siegfried Bublitz · version 5.7

I have several hundred file path names in a buffer, each filling a line, e.g. created with vim tip # 659.

About half of them are help files, starting with './help/' which I want to delete, but I want to keep the german ones, starting with './help/de/'. Here comes how I do it with Vim:

:global:^./help/:if (match(getline(line(".")), '^./help/de/') == -1) | delete | endif


Would this also do it?


No, because lines like


are not deleted. Instead use


to delete all lines starting with './help/' but keep all lines starting with './help/de/'


:help :global

This will only work if each line in the file starts with './help'.