In insert-mode, I would like to extract the current line number I'm editing in a "variable"/memory/buffer, and to be able to paste it through a remapping.
I know that :echo line(".") gives me the line number.
I have found how to insert the line number at the beginning of each line, using :s/^/\=line(".").
But I would like to have a remapping like :
:inoremap \l <Esc>:echo line(".") > buffer<CR> p
that would extract the line number and paste it at my current cursor position.
(Sources of previous searches : How to add permanent line numbers to a file?)
let) ? – nobe4 Apr 12 '16 at 10:01:letit is. But you can save it into a variable (:let foo = ...) or into a register (:let @a = ...). – romainl Apr 12 '16 at 10:03