I have a file "file.txt" in which some rows begins with numbers.
E.g. file.txt:
1 bla bla 390
23 foo foo 100
# bar bar
some word
45 junk
Is there an easy and fast way to delete the numbers (and the space) from all the lines that start with a number, while deleting only the space from the others?
I would like a command so that the file then looks like:
bla bla 390
foo foo 100
# bar bar
some word
junk
You can use the command editor line:
:%s/^\d*//
This uses the global search %s
to find any line that begins with a digit \d*
and replace it with nothing //
.
Additionally, if you need to remove the extra space after the number as well:
:%s/^\d* //
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With