Vim Tips Wiki
Advertisement
Tip 831 Printable Monobook Previous Next

created December 8, 2004 · complexity basic · author Andrew Nikitin · version 6.0


The command

%s/\(\.\d\+\)\@<=0\+\>//g

will strip all trailing (meaningless) zeroes in decimal fractions. Some of my data files lost 50% fat after this procedure and also became much more human readable.

I guess the "correct" regular expression should be

\(\.\d\{-1,}\)\@<=0\+\>

(since the intention is to preserve just one zero that comes right after decimal point), but for some reason the original expression works as well.

Comments


Advertisement