How to make Vim write lines into a file according to a very simple arithmetic pattern?
Example:
foo1
foo2
foo3
...
foo99
foo100
I came up with the following solution using Ex commands
:for i in range(1,100)
: execute "normal ofoo" . i
:endfor
but I am convinced there must be something more straightforward.
Edit multiple linesUse Ctrl+V to enter visual block mode Move down with jj to select the columns of text in the lines you want to comment. Then hit Shift+I and type the text you want to insert. Then press Escape, the inserted text will appear on all lines.
Calling A Function Vim has a :call command to call a function. The call command does not output the return value. Let's call it with echo . To clear any confusion, you have just used two different call commands: the :call command-line command and the call() function.
I would do it with macro.
First type one line:
foo1
then
qqYp<c-a>q
finally replay the macro:
98@q
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With