i have a few words and need to copy word length in to clipboard.

Tried :!wc or g and Gv but don't work

2 Answers 2


If your Vim has:

  • :help wordcount()
  • and clipboard support (:echo has('clipboard') echoes 1),

you could create a custom mapping:

xnoremap <key> <Cmd>let @+ = wordcount().visual_words<CR>

that you would use like this:


where you:

  1. visually select your words,
  2. and press <key>.

See :help <Cmd> and :help wordcount().

  • For me don't work. I have wordcount(), <Cmd>, has('clipboard') === 1 Using neovim 0.9 My key <C-t> <Cmd>let @+ = wordcount().visual_words<CR> Select one word and press C-t, and nothing.
    – serii
    Jul 5, 2023 at 6:03

Finded solution. Copy word to clipboard. And map copy length to clipboard +

nmap <C-t> :let @+ = len(@+)<CR> 

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .