P.He
P.He

Reputation: 31

MacOs Terminal Vim Copy to System Clipboard

I am using Homebrew Vim from MacOS Terminal. The problem I am having now is to copy in vim to System Clipboard. I follow the guide online, which told me to use "+y after selection texts in visual mode. However, when I hit the corresponding keys on "+y, the system responds with a sound indicating that such key combination is illegal. What am I doing wrong?

I did what is suggested. Here is what my dot file looks like:

 set runtimepath+=~/.vim_runtime


 source ~/.vim_runtime/vimrcs/basic.vim
 source ~/.vim_runtime/vimrcs/filetypes.vim
 source ~/.vim_runtime/vimrcs/plugins_config.vim
 source ~/.vim_runtime/vimrcs/extended.vim

 try
 source ~/.vim_runtime/my_configs.vim
 catch
 endtry


 " Define Key Mapping
 inoremap jj <Esc>

 set clipboard=unnamedplus

 " Run Python file with one command
 nnoremap <buffer> <C-M> :exec '!python' shellescape(@%, 1)<cr>

 "YouCompleteMe virtual env config
 let g:ycm_global_ycm_extra_conf = '~/.vim/.ycm_extra_conf.py'

Further, the :reg does not show the "+ or "* registry.

Upvotes: 2

Views: 2439

Answers (1)

Songcheng Li
Songcheng Li

Reputation: 181

You can try with add the line:

set clipboard=unnamed

to your .vimrc ^1. For using + you might want to try with set clipboard=unnamedplus.

If you are not sure how to do this, just type in:

cd ~ && echo 'set clipboard=unnamedplus' >> .vimrc

See more information by :h clipboard-unnamedplus.

Notice that this this option works only in vim that is compiled with X11 & clipboard feature.

Regards

Upvotes: 1

Related Questions