In neovim 0.4.3-3 in normal mode this command :
:put=range(1,4)
will put numbered list from 1 to 4
but when i want to put numbers only in blank lines like this:
:g/^$/norm :put=range(1,14)
it is not working as expected – only highlighting empty lines but put is not working, why ?
From :help :normal:
{commands}should be a complete command. If{commands}does not finish a command, the last one will be aborted as if<Esc>or<C-C>was typed. A:command must be completed as well.
You can fix that by adding an extra “Enter” character at the end of your command, which you can enter with:
Ctrl+V, Enter
It will display as a ^M in Vim:
:g/^$/norm :put=range(1,14)^M
(There are ways to avoid having to enter a literal “Enter” in your command. For instance, the :execute command is often used for that.)
But in this case there’s a much simpler solution, which is to drop the :normal altogether and just have :g run :put directly!
:g/^$/put=range(1,14)
The :g command will run an Ex command for each line it matches and :put is an Ex command, so you can just cut the middle man here.
Note that what this command does is append 14 new numbered lines after each blank line in your buffer. Not sure if that’s actually what you intended with it or not.
Source: vim – nvim norm command – Unix & Linux Stack Exchange