Spacevim: Copy and paste in the system clipboard

Created on 26 Sep 2018  ·  14Comments  ·  Source: SpaceVim/SpaceVim

Hello,

I have tried several solutions to be able to perform copy / paste operations in the system clipboard by default, like "*yy and "*p do, unsuccessfully. Visual copy / paste operations work as expected but I'm trying to figure out (I did read the FAQ and the documentation of course) how I can use the system clipboard by default, in order to be able to paste contents in another _vim_ process, a terminal, or another application.

I have tried to:

  • Use more layers provided by SpaceVim ;
  • Use set clipboard=unnamed (as well as _unnamedplus_ or the combination of both values) ;
  • Use set guioptions+=a ;
  • Remap <Leader> to see if the behaviour keeps being the same.

I saw that some people sometimes remap C-c / C-v keys but I guess that there is a better way to achieve this.

I have put some details in the _Reproduce ways_ section, but I would like to also mention that:

  • When using <Leader>, it seems that I have to wait for about one second (when the menu is displayed) before pressing \ y. Am I right or is there a way to do this more quickly?

  • I was previously using the mouse to copy to the _X11_ clipboard (vim, terminal, or in another places), and then a middle-button click to paste the content, but it also pastes lines numbers, columns characters, that's why I'm looking for another method now.

Thanks a lot.

PS: I have found a lot of posts on this topic, sorry for opening another issue.

Environment Information

  • OS: linux
  • vim version: 8.0.1453
  • neovim version: -
  • SpaceVim version: 0.9.0-dev
  • SpaceVim status:
On branch master
Your branch is up to date with 'origin/master'.

nothing to commit, working tree clean

The reproduce ways from Vim starting (Required!)

At the moment:

  1. If I use C-c / C-v, the content can be pasted in the current _vim_ process only ;
  2. If I use <Leader> \ y, the content is yanked. Though, using p in another terminal with not allow to paste the same content.
  3. If I use "*yy and "*p, it works as expected but I believe that _SpaceVim_ provides shortcuts ; am I right ?

Output of the :SPDebugInfo!

SpaceVim debug information

SpaceVim options :

  auto_disable_touchpad = 1
  autocomplete_method = 'ycm'
  autocomplete_parens = 1
  background = 'dark'
  bootstrap_after = 'myspacevim#after'
  bootstrap_before = 'myspacevim#before'
  buffer_index_type = 4
  checkinstall = 1
  colorscheme = 'gruvbox'
  colorscheme_bg = 'dark'
  colorscheme_default = 'desert'
  custom_color_palette = []
  custom_plugins = [['crazy-canux/icinga2.vim', {'name': 'crazy-canux/icinga2.vim', 'merged': 0}], ['saltstack/salt-vim', {'name': 'saltstack/salt-vim', 'merged': 0}]]
  debug_level = 1
  default_indent = 2
  disabled_plugins = []
  enable_ale = 0
  enable_cursorcolumn = 0
  enable_cursorline = 1
  enable_debug = 0
  enable_googlesuggest = 0
  enable_guicolors = 1
  enable_insert_leader = 1
  enable_javacomplete2_py = 0
  enable_key_frequency = 0
  enable_language_specific_leader = 1
  enable_neocomplcache = 0
  enable_neomake = 1
  enable_os_fileformat_icon = 0
  enable_powerline_fonts = 1
  enable_statusline_display_mode = 0
  enable_statusline_mode = 0
  enable_tabline_filetype_icon = 1
  enable_vimfiler_filetypeicon = 0
  enable_vimfiler_gitstatus = 0
  enable_vimfiler_welcome = 1
  enable_ycm = 1
  error_symbol = '✖'
  expand_tab = 1
  filemanager = 'vimfiler'
  filetype_icons = {}
  force_global_config = 0
  gitcommit_issue_icon = ''
  gitcommit_pr_icon = ''
  github_username = ''
  guifont = ''
  hiddenfileinfo = 1
  hosts_url = 'https://raw.githubusercontent.com/racaljk/hosts/master/hosts'
  info_symbol = 'ⓘ'
  keep_server_alive = 1
  language = ''
  leader_guide_default_group_name = ''
  leader_guide_flatten = 1
  leader_guide_hspace = 5
  leader_guide_max_size = 0
  leader_guide_position = 'botright'
  leader_guide_run_map_on_popup = 1
  leader_guide_sort_horizontal = 0
  leader_guide_submode_mappings = {'<C-C>': 'win_close'}
  leader_guide_vertical = 0
  lint_on_save = 1
  lint_on_the_fly = 0
  max_column = 120
  plugin_bundle_dir = '/home/aanriot/.cache/vimfiles/'
  plugin_manager = 'dein'
  plugin_manager_processes = 16
  plugin_name = 'vimshell.vim'
  project_rooter_automatically = 1
  project_rooter_patterns = ['.git/', '_darcs/', '.hg/', '.bzr/', '.svn/']
  realtime_leader_guide = 1
  relativenumber = 0
  search_tools = ['rg', 'ag', 'pt', 'ack', 'grep']
  sidebar_direction = ''
  sidebar_width = 30
  simple_mode = 0
  smartcloseignoreft = ['tagbar', 'vimfiler', 'SpaceVimRunner', 'SpaceVimREPL', 'SpaceVimQuickFix', 'HelpDescribe', 'VebuggerShell', 'VebuggerTerminal', 'SpaceVimTabsManager']
  smartcloseignorewin = ['__Tagbar__', 'vimfiler:default']
  snippet_engine = 'ultisnips'
  src_root = 'E:\sources\'
  statusline_inactive_separator = 'arrow'
  statusline_left_sections = ['winnr', 'filename', 'major mode', 'syntax checking', 'minor mode lighters']
  statusline_right_sections = ['fileformat', 'cursorpos', 'percentage']
  statusline_separator = 'arrow'
  statusline_unicode_symbols = 1
  terminal_cursor_shape = 2
  version = '0.9.0-dev'
  vim_help_language = 'en'
  vimcompatible = 0
  warning_symbol = '⚠'
  wildignore = '*/tmp/*,*.so,*.swp,*.zip,*.class,tags,*.jpg,*.ttf,*.TTF,*.png,*/target/*,.git,.svn,.hg,.DS_Store,*.svg'
  windows_index_type = 0
  windows_leader = 's'
  windows_smartclose = 'q'

SpaceVim layers :

[[layers]]
  name="autocomplete"
  auto-completion-return-key-behavior='complete'
  auto-completion-tab-key-behavior='cycle'
[[layers]]
  name="checkers"
[[layers]]
  name="format"
[[layers]]
  name="edit"
[[layers]]
  name="ui"
[[layers]]
  name="core"
[[layers]]
  name="core#banner"
[[layers]]
  name="core#statusline"
[[layers]]
  name="core#tabline"
[[layers]]
  name="default"
[[layers]]
  name="git"
[[layers]]
  name="lang#python"
[[layers]]
  name="lang#markdown"
[[layers]]
  name="lang#latex"
[[layers]]
  name="shell"
  default_position='top'
  default_height=30
[[layers]]
  name="-l"

SpaceVim Health checking :

SpaceVim clipboard support check report:
Checking +clipboard:
Failed : to support +clipboard, you need recompile your vim with +clipboard support.
SpaceVim environment check report:
Current progpath: vi(/usr/bin/vim.basic)
version: 800
OS: linux
SpaceVim lua support check report:
Checking +lua:
Failed : to support +lua, you need recompile your vim with +lua support.
SpaceVim python support check report:
Checking +python3:
SUCCEED!
Checking +python:
Failed : to support +python, Please install vim-gik, or build from sources.

SpaceVim runtime log :

[ SpaceVim ] : logger file  does not exists, only log for current process will be shown!
[ SpaceVim ] [09:23:02] [ Info ] SpaceVim startup status is: [1, '/home/aanriot/repos/fraudbuster/saltstates']
[ SpaceVim ] [09:23:02] [ Info ] Can not find project local config, start to loadding global config
[ SpaceVim ] [09:23:02] [ Info ] YCM only support ultisnips, change g:spacevim_snippet_engine to ultisnips
[ SpaceVim ] [09:23:03] [ Info ] Find project root('.git/',''):/home/aanriot/repos/fraudbuster/saltstates/.git/
[ SpaceVim ] [09:23:03] [ Info ] change to root:/home/aanriot/repos/fraudbuster/saltstates
[ SpaceVim ] [09:23:03] [ Info ] try to open SpaceVim welcome page
[ SpaceVim ] [09:23:03] [ Info ] change to root:/home/aanriot/repos/fraudbuster/saltstates
[ SpaceVim ] [09:23:04] [ Info ] Find project root('.git/',''):/home/aanriot/repos/fraudbuster/saltstates/.git/
[ SpaceVim ] [09:23:04] [ Info ] change to root:/home/aanriot/repos/fraudbuster/saltstates
[ SpaceVim ] [09:23:06] [ Info ] Find project root('.git/','/home/aanriot/repos/fraudbuster/saltstates/SpaceVimLayers'):/home/aanriot/repos/fraudbuster/saltstates/.git/
[ SpaceVim ] [09:23:06] [ Info ] change to root:/home/aanriot/repos/fraudbuster/saltstates
[ SpaceVim ] [09:24:47] [ Info ] change to root:/home/aanriot/repos/fraudbuster/saltstates

Most helpful comment

How about providing instructions in english?

To copy, make sure you're not in edit mode, so first hit esc

The default leader key is \

so copy & paste should be:

  • copy: \y
  • paste: \p

All 14 comments

@aanriot in SpaceVim, we use Leader + y and Leader + p to copy and paster from system clipboard. It is mapped to "+yy and "+p. I do not know why it does not work for you, maybe you vim do not support register +?

@aanriot what is the output of vim --version?

Hello @wsdjeg.

Thanks for your answer. Indeed, it could be that, I should try again with _neovim_.

On _Linux_ / _X11_, I have to use the * register instead of + to be able to use the middle button of the mouse to paste contents, right?

Here it is the _vim_ version I'm using:

VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Apr 10 2018 21:31:58)
Rustines incluses : 1-1453
Modifié par [email protected]
Compilé par [email protected]
Énorme version sans interface graphique.
  Fonctionnalités incluses (+) ou non (-) :
+acl               +farsi             +mouse_sgr         -tag_any_white
+arabic            +file_in_path      -mouse_sysmouse    -tcl
+autocmd           +find_in_path      +mouse_urxvt       +termguicolors
-autoservername    +float             +mouse_xterm       +terminal
-balloon_eval      +folding           +multi_byte        +terminfo
+balloon_eval_term -footer            +multi_lang        +termresponse
-browse            +fork()            -mzscheme          +textobjects
++builtin_terms    +gettext           +netbeans_intg     +timers
+byte_offset       -hangul_input      +num64             +title
+channel           +iconv             +packages          -toolbar
+cindent           +insert_expand     +path_extra        +user_commands
-clientserver      +job               -perl              +vertsplit
-clipboard         +jumplist          +persistent_undo   +virtualedit
+cmdline_compl     +keymap            +postscript        +visual
+cmdline_hist      +lambda            +printer           +visualextra
+cmdline_info      +langmap           +profile           +viminfo
+comments          +libcall           -python            +vreplace
+conceal           +linebreak         +python3           +wildignore
+cryptv            +lispindent        +quickfix          +wildmenu
+cscope            +listcmds          +reltime           +windows
+cursorbind        +localmap          +rightleft         +writebackup
+cursorshape       -lua               -ruby              -X11
+dialog_con        +menu              +scrollbind        -xfontset
+diff              +mksession         +signs             -xim
+digraphs          +modify_fname      +smartindent       -xpm
-dnd               +mouse             +startuptime       -xsmp
-ebcdic            -mouseshape        +statusline        -xterm_clipboard
+emacs_tags        +mouse_dec         -sun_workshop      -xterm_save
+eval              +mouse_gpm         +syntax            
+ex_extra          -mouse_jsbterm     +tag_binary        
+extra_search      +mouse_netterm     +tag_old_static    
         fichier vimrc système : "$VIM/vimrc"
     fichier vimrc utilisateur : "$HOME/.vimrc"
 2me fichier vimrc utilisateur : "~/.vim/vimrc"
      fichier exrc utilisateur : "$HOME/.exrc"
 fichier de valeurs par défaut : "$VIMRUNTIME/defaults.vim"
               $VIM par défaut : "/usr/share/vim"
Compilation : gcc -c -I. -Iproto -DHAVE_CONFIG_H   -Wdate-time  -g -O2 -fdebug-prefix-map=/build/vim-NQEcoP/vim-8.0.1453=. -fstack-protector-strong -Wformat -Werror=format-security -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1       
Édition de liens : gcc   -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now -Wl,--as-needed -o vim        -lm -ltinfo -lnsl  -lselinux  -lacl -lattr -lgpm -ldl     -L/usr/lib/python3.6/config-3.6m-x86_64-linux-gnu -lpython3.6m -lpthread -ldl -lutil -lm      

you need to recompile your vim with +clipboard support

Thanks @wsdjeg .

and I just fix it, in your vim, now you can use Leader y and Leader p, it will use registers *.

Great, thanks @wsdjeg . On Ubuntu, I have installed vim-gtk to get the +clipboard support.

what the Leader key? SPC doesn't work.

what the Leader key? SPC doesn't work.

default is 's' in Normal Mode.

what the Leader key? SPC doesn't work.

\ key if you did not change it

How about providing instructions in english? Currently on OSX I am using this

Copy to clipboard: "y
To paste clipboard: "
p

How about providing instructions in english?

To copy, make sure you're not in edit mode, so first hit esc

The default leader key is \

so copy & paste should be:

  • copy: \y
  • paste: \p

I can't ggvG copy/paste when i open spacevim from SSH connection, is there an easy way to do it ?

If you want to access the system clipboard just add the default layer in the init.toml file like this->

1) Press SPC f v d to open the Spacevim configuration file(init.toml)
2) Add the following code to the file
[[layers]]
name = "default"

KEYBINDS

y —> yank(copy) to system clipboard
p —> paste from system clipboard

Refer this—> https://spacevim.org/layers/default/

Was this page helpful?
0 / 5 - 0 ratings

Related issues

everettjf picture everettjf  ·  5Comments

dzintars picture dzintars  ·  3Comments

wsdjeg picture wsdjeg  ·  3Comments

fmind picture fmind  ·  3Comments

linwaytin picture linwaytin  ·  4Comments