Vim: Replace all dots but the last one in a line

vim

Solution

This seems to do the trick:

%s/\.\(.*\.\)\@=/ /g

`\@=` is a lookahead. It only matches a full stop if there are any following full stops.

See `:help zero-width`.

Problem

I'm looking for a way to replace all dots in a line except the last one. Example: `Blah - whatever - foo.bar.baz.avi` should become `Blah - whatever - foo bar bar.avi` Since I'll have more than one line in the file and the amount of dots varies in each line I'm looking for a generic solution and not something like "Replace the first X matches" with X being a constant.

Original source