kiran6
kiran6

Reputation: 1295

Copy/paste issue with my .vimrc file

When i try to copy in the visual mode and then paste it, its just pasting a new line instead of copied line. When the same thing done under root where it dosent use .vimrc it works fine.

This is the .vimrc that i am currently using. Any help is appreciated and one thing to note same .vimrc when used in linux it works fine.

Upvotes: 1

Views: 441

Answers (2)

sudo bangbang
sudo bangbang

Reputation: 28169

:help unnamedplus

provides me this information

                                       clipboard-unnamedplus
unnamedplus     A variant of the "unnamed" flag which uses the
                clipboard register '+' (quoteplus) instead of
                register '*' for all yank, delete, change and put
                operations which would normally go to the unnamed
                register.  When "unnamed" is also included to the
                option, yank operations (but not delete, change or
                put) will additionally copy the text into register
                '*'.
                Only available with the +X11 feature.
                Availability can be checked with:
                        if has('unnamedplus')

vim.wikia article on Mac OS X clipboard sharing suggests to use

set clipboard=unnamed

Also take a look at options like autoselect and autoselectplus

:help autoselect
                                           clipboard-autoselect
    autoselect      Works like the 'a' flag in 'guioptions': If present,
                    then whenever Visual mode is started, or the Visual
                    area extended, Vim tries to become the owner of the
                    windowing system's global selection or put the
                    selected text on the clipboard used by the selection
                    register "*.  See guioptions_a and quotestar for
                    details.  When the GUI is active, the 'a' flag in
                    'guioptions' is used, when the GUI is not active, this
                    "autoselect" flag is used.
                    Also applies to the modeless selection.

                                           clipboard-autoselectplus
    autoselectplus  Like "autoselect" but using the + register instead of
                    the * register.  Compare to the 'P' flag in
                    'guioptions'.

Upvotes: 1

skeletalmonkey
skeletalmonkey

Reputation: 736

Since you mentioned it does work under Linux, I assume your error is on Windows or OSX. As mentioned by @sudobangbang your issue is with the line set clipboard=unnamedplus

What this does is set the default copy buffer for vim to be + which is vim's alias to the X Window clipboard used by Linux. Not sure why it's only giving you new lines but it's probably to do with how it interacts with the OS

To get this to work for Windows and OSX you'll want to use the command set clipboard=unnamed which sets the copy buffer to * which is the alias for the clipboard in Windows/OSX.

However if you remove that line entirely you can manually copy/paste from the system copy buffer by doing "*y and "*pusing " to reference the * buffer followed by your command

Upvotes: 0

Related Questions