I copy and paste a lot of code off of various websites and back into gVim. Which is all good but most of the time that copy and paste comes with line numbers in front of every line. While that might not be a big deal for 10 LOC or less, but for anything more than that your looking at a considerable amount of time wasted trying to delete all those lines, even with the dot command (pressing . in vim will repeat the last full edit series thing again).
So this is where regex and vim come to the rescue. You basically just do a find and replace using regular expressions.
%s/^[0-9]*\s//
That my friend will remove the line number from the beginning of every line. This does take into account two assumptions though. One, your line numbers are at the beginning of every line, and two, your line numbers always have at least one space after them. It will then replace all your line numbers with nothing. It basically just deletes them.
Enjoy the Penguins!
2 Comments
I always end up doing a column select + delete. Seems like I get it done with fewer keystrokes and brain usage
— ferdy
thanks for the tip. Should come in handy.