How to add line numbers to range of lines in Vim?
With :%s/^/\=line(‘.’)/ EDIT: to sum up the comments. This command can be tweaked as much as you want. Let’s say you want to add numbers in front of lines from a visual selection (V + move), and you want the numbering to start at 42. :'<,’>s/^/\=(line(‘.’)-line(“‘<“)+42)/ If you want to add a string between the … Read more