Szkieletor
Szkieletor

Reputation: 1

when an option of clipboard, "unnamedplus", is included in vimrc, E518 error says that's unknown

In order to enable vim to access clipboard when yanking, I added the following script into ~/.vimrc.

:set clipboard = unnamedplus

After this, when I tried to use vim, the following error message was always shown:

E518: unknown option: unnamedplus

But unnamedplus option is common and can be seen in other stackoverflow's questions such as this.

Why my .vimrc can't find options of clipboard?

My all .vimrc is below:

1 :set autoindent
2 :set number
3 :imap <C-j> <esc>
4 :noremap! <C-j> <esc>
5 :set clipboard = unnamedplus
6 :colorscheme elflord

The OS is Ubuntu 14.04 LTS. The version of vim is VIM - Vi IMproved 7.4 and Huge version with GTK2-GNOME GUI.

Upvotes: 0

Views: 1502

Answers (2)

kivantium
kivantium

Reputation: 86

set does not allow white space after =.

See :help set for more information.

:se[t] {option}={value}     or
:se[t] {option}:{value}

     ... (unrelated explanations)

    White space between {option} and '=' is allowed and will be ignored.
    White space between '=' and {value} is not allowed.

By the way, you can omit colon when you write .vimrc or other Vim script files. So your .vimrc should be like

set autoindent
set number
imap <C-j> <esc>
noremap! <C-j> <esc>
set clipboard=unnamedplus
colorscheme elflord

Upvotes: 0

romainl
romainl

Reputation: 196789

  1. In general, "options" depend on "features". If Vim is not built with feature A, options depending on feature A won't be available.

  2. But that's irrelevant. The problem, here, is that you put spaces around the equal sign so Vim thinks unnamedplus is the name of an option. The right syntax would be either:

    set clipboard=unnamedplus
    

    or:

    set clipboard =unnamedplus
    

    From :help :set-args:

    White space between {option} and '=' is allowed and will be ignored.
    White space between '=' and {value} is not allowed.
    

    The "no-spaces" version is kind of a de-facto standard.

Upvotes: 1

Related Questions