Use case:
In a JS file, I have an expression like:
if (someVar === 'someValue') {
statements;
}
and, for debugging purposes, I sometimes want to include a console.log
in the line above:
console.log('someVar:', someVar);
if (someVar === 'someValue') {
statements;
}
(Working) Attempt:
I want to have some keybinding to achieve this, so I tried:
nnoremap <Leader>L "ayiwOconsole.log(':', );<Esc>2F'"apf "ap
that basically yanks word under cursor to register a
, then writes an empty console.log(':', );
template in the line above, moves to the desired positions and pastes register a
twice.
It works, but it feels some-way dirty. Can you think of a more elegant way to do the same?