Assume I have a text file containing some strings:string_gstring_rstring_qqwerstring_pstring_fstring_3qwstring_estring_qwAnd I need to insert increasing or decreasing numbers before the strings:001 string_g002 string_r003 string_qqwer004 string_p005 string_f006 string_3qw007 string_e008 string_qwJust to avoid confusion:I do not want line numbers to be displayed. I know how that works. What I want is an actual number at the beginning of each string within the text.Is there a way to do this automatically with vim?I can mark the beginning of each string with CTRL-V then type : to enter the execute mode, which will allow me to execute command on the selection via :'<,'> but Im stuck there.
Insert single successive numbers at the beginning of each line in a text file with Vim
text processing;vim
Use external unix command nl.:'<,'>!nl -w 3 -n rz -s' '