Code Monkey home page Code Monkey logo

vim-wayland-clipboard's Introduction

vim-wayland-clipboard

jasoncarloscox.com/creations/vim-wayland-clipboard

This plugin allows Vim to integrate with the Wayland clipboard when using the + register. This means you can yank text into the + register and paste it in other Wayland programs, or copy text in other Wayland programs and paste it in Vim from the + register. Operators and counts work, too!

When running Vim outside of Wayland, the + register continues to work as normal.

Requirements

For this plugin to work, you need wl-clipboard installed, and Vim must be compiled with the +eval feature.

Installation

Use Vim8's built-in packages:

  1. mkdir -p ~/.vim/pack/vim-wayland-clipboard/start/
  2. git clone https://github.com/jasonccox/vim-wayland-clipboard.git ~/.vim/pack/vim-wayland-clipboard/start/vim-wayland-clipboard

Usage and Features

Just use "+y, "+p, <C-R>+, and friends as you always do. Specifically, here's what's supported:

  • Any yank command that starts with "+ (e.g. "+yy or "+yiw) in insert and visual modes.
  • Pasting in normal and visual modes with "+p or "+P.
  • Pasting in insert mode with <C-R>+, <C-R><C-R>+, <C-R><C-O>+, or <C-R><C-P>+.
  • Yanking and pasting (p and P in normal and visual modes) with clipboard=unnamedplus.

If you need more functionality, consider checking out vim-fakeclip.

Notes

Passing extra arguments to wl-copy or wl-paste

If you want to pass extra arguments to wl-copy, set g:wayland_clipboard_copy_args to a list of strings, one per argument. For example, to copy to the primary clipboard and only allow the contents to be pasted once, you could do the following:

let g:wayland_clipboard_copy_args = ['--primary', '--paste-once']

To pass extra arguments to wl-paste, use g:wayland_clipboard_paste_args in the same way.

Clobbering the w Register

On Vim builds without clipboard, the + register doesn't work for yanking. My solution is to map "+ to "w and send the w register to the Wayland clipboard as well. (This only occurs when the clipboard feature is missing.) If you use the w register for other things and don't want it to clobber your system clipboard, put let g:wayland_clipboard_no_plus_to_w = 1 in your vimrc to disable this feature.

Non-recursive Mappings

This plugin uses mappings of "+p, <C-R>+, "+, etc. to do its job. As a result, it won't work with existing non-recursive mappings that run these commands, e.g. nnoremap <Leader>p "+p. If you have mappings like these, you'll need to use their recursive counterparts instead for the plugin to work.

Contributing

Contributions are welcome! You can send questions, bug reports, patches, etc. by email to ~jcc/[email protected]. (Don't know how to contribute via email? Check out the interactive tutorial at git-send-email.io, or email me for help.)

GitHub issues and pull requests are fine, too.

vim-wayland-clipboard's People

Contributors

bitkeen avatar chenxiaolong avatar jasonccox avatar razimantv avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.