small medium large xlarge

Back to: All Forums  Practical Vim
02 Jul 2013, 16:40
Giuseppe Maxia (2 posts)

The task described in tip-70 (adding numbers to a list) can be easily achieved (in Unix OS) using nl

:1,$ ! nl

And if we want to format the numbers exactly as the exercise requires, we can run:

:1,$ ! nl -s ‘) ‘ -w 2

15 Jul 2013, 07:55
Drew Neil (24 posts)

That’s a neat solution! The solution I offered in tip 70 was not meant to be the quickest or the best. I included it because it demonstrates several of Vim’s power features in combination: the expression register, rudimentary Vimscript, and executing a macro across a range using the :normal @a command.

  You must be logged in to comment