Vim how to replace leading line number from source file

Today I needed to replace the leading line number from a source file that was forwarded to me probably gotten from an html representation of a source repository of some sort. I know, definitely not the best way to acquire a source file this way but a good exercise nonetheless.

In Vim the following would do the trick:


%    --> for each line
^    --> beginning of the current line
\s*  --> match any leading space characters
\d\+ --> match any number of digits (one or more)
     --> replace with nothing

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s