2

I would like to copy a selected word that the cursor is on to the clipboard. Is there a way to do this.

1

4 Answers 4

3

If support for clipboard is built into your Vim, clipboard is mapped to register *, so you use it the same as any other register. So, for example, to copy the word under cursor to clipboard you do "*yiw. To copy current line "*yy. To paste from clipboard "*p

Sign up to request clarification or add additional context in comments.

Comments

1

Perhaps you just want to do this:

viwp 

which will visually select a new word, and paste over it.

Now, if you don't want to lose your register when doing this, you can also put in your vimrc:

xnoremap p pgvy 

Comments

1

First at all you must check if the clipboard feature on your VIM is enable or not. For that use the --version parameter (vim --version)

If not (-clipboard), you can use a gtk vim edition or compile VIM manually. If yes (+clipboard), in normal mode "+yiw on your word for copy it in your clipboard.

Comments

0

Follow instruction in https://stackoverflow.com/a/65666057/9384511

Once you have set up your vim as per above link, you will be able to copy single or multiple lines from vim to clipboard by pressing Ctrlc. And paste from clipboard to vim by pressing Ctrlp

Now to copy just a single word to clipboard press bveCtrlc

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.