Hi I have a function that adds numbers to the begining of lines and I want it to do it to each line in a visual selection (to create numbered lists in my text). There is however the problem that the function is called for each selected line and not once for the entire visual selection. can anyone help me modify it such that it will work on visual selected lines (<S-V>):
function! Listing2() " set line numbers in front of lines let beginning=line("'<") let ending= line("'>") let difsize = ending-beginning let pre = ' ' while (beginning <= ending) if match(ending, '^9*$') == 0 let pre = pre . '0' endif call setline(ending, pre . difsize . "\t" . getline(ending)) let ending=ending-1 let difsize=difsize-1 endwhile endfunction :vmap :call Listing2()<cr> I would prefer not to use a global counter. -- Kim Schulz | Private : http://www.schulz.dk [EMAIL PROTECTED] | Business: http://www.devteam.dk +45 5190 4262 | Sparetime: http://www.fundanemt.com