1

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

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

romainl
  • 22,554
  • 2
  • 49
  • 59
serii
  • 11
  • 1

2 Answers2

1

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:

v{motion}<key>

where you:

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

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

romainl
  • 22,554
  • 2
  • 49
  • 59
  • For me don't work. I have wordcount(), , has('clipboard') === 1 Using neovim 0.9 My key ` let @+ = wordcount().visual_words` Select one word and press C-t, and nothing. – serii Jul 05 '23 at 06:03
0

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

nmap <C-t> :let @+ = len(@+)<CR> 
serii
  • 11
  • 1