I am using Vim 8.0 (in the Terminal), compiled by Homebrew, on Mac OS 10.12.6. I am trying to enable copy to clipboard (and paste from clipboard) using the usual yank/put commands. I've actually succeeded in doing this (following various online guides) by creating a .vimrc file in my home directory and adding the single line set clipboard=unnamed
. However, this has had the undesired side effect of preventing the nice extension-specific syntax highlighting (that was enabled by default with the installation) from being loaded when vim opens (for example, when I open a .py file the text is now all white). Is there some way of enabling copy to clipboard without destroying the syntax highlighting?
If you have no vimrc
, vim loads a defaults.vim
file, but once you add a custom vimrc
, vim stops loading that file. This was introduced in Vim 8.0, and you can get more info by typing :h defaults.vim
within vim, but here are your options to fix the issue:
SOLUTION 1:
Source the defaults.vim
file into your .vimrc
(this is the method mentioned in the vim help files - see :help defaults.vim
). Just add these lines to the top of your .vimrc
:
unlet! skip_defaults_vim
source $VIMRUNTIME/defaults.vim
SOLUTION 2:
Copy the stuff you like from defaults.vim
into your own config.
This involves a few steps:
:echo $VIMRUNTIME
inside of vim and hitting enter./usr/local/share/vim/vim80/
) and find the defaults.vim
file..vimrc
.Hope this helps!