For a handful of rows, I wouldn't bother: pressing M-S-<down>
a few times is easy. If you are adding rows at the end of the table, pressing RET
a bunch of times is even easier.
The next step up in complexity is Marco Wahl's macro-based solution.
The next step up is to write your own function which takes a numeric prefix and does the row insertion that many times:
(defun n-org-insert-row (n)
(interactive "p")
(dotimes (i n) (org-table-insert-row 'below)))
You call it like this: C-u 23 M-x n-org-insert-row
. If you leave out the numeric prefix, n
defaults to 1. You can also bind the function to a key but I won't go into that here: you can find
out about it elsewhere on this site, e.g. here, although there is no substitute for the documentation.
In the next step up, you can write a generic "do this n times" function and tell it explicitly when you call it what "this" (the thing that you want to repeat) is:
(defun n-do-this (n this)
(dotimes (i n) (funcall this)))
where this
is a function of no arguments. You can do what you want by evaluating this form:
(n-do-this 23 (lambda () (org-table-insert-row 'below)))
where you pass in an anonymous function that inserts a row. You can then define n-org-insert-row
like this:
(defun n-org-insert-row (n)
(interactive "p")
(n-do-this n (lambda () (org-table-insert-row 'below)))
This is a different implementation from the earlier one, but "it looks the same from the outside": it is called the same way and it behaves the same way.
The nice thing about n-do-this
is that it can be asked to do anything n times, not just insert a row in a table.
I'll stop here, but as I hope you can see, the sky's the limit.