In normal mode I want to be able to select a word and when I press <leader>i yield the following string in next line, The word is <word_that_was_highlighted>. Is it possible to do this in vim? I attempted a solution using nnoremap like as follows but that didn't work.

nnoremap <leader>i :let @h=@*<c-r>"hp

Here I was attempting to paste the content of register * into h, and then paste that onto a new line.

  • 1
    I'm not sure I fully understand your question, are you looking for something like nnoremap <leader>i yiwoThe word is <Esc>p which yanks the current word (yiw), adds a new line (o) and write The word is before going to normal mode and pasting the previously yanked word?
    – statox
    Jan 7, 2020 at 10:08
  • Yes exactly. Please add this as an answer
    – hyde
    Jan 7, 2020 at 10:15
  • 2
    This is pretty much the same as How to Insert a console.log for word under cursor in new line
    – Matt
    Jan 7, 2020 at 10:20

1 Answer 1


As discussed in the comments you are looking for the following mapping

nnoremap <leader>i yiwoThe word is <Esc>p
                   yiw                     Yank the word under the cursor
                      o                    Create a new line under the current one and enter insert mode
                       The word is         Type this string literraly
                                   <Esc>   Switch back to normal mode
                                        p  Past the word you yanked before

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.