Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
doc/tags
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
Forked differences from main (christoomey version):
===========
paste now mimics native vim paste instead of whatever chris was using.
removed all plugin bindings (since I didn't like them). Must now explicitly set in .vimrc
personal .vimrc:
```.vimrc
nmap <leader>y <Plug>SystemCopy
nmap <leader>yy <Plug>SystemCopyLine
nmap <leader>Y <Plug>SystemCopyLine
xmap <leader>y <Plug>SystemCopy
xmap <leader>p <Plug>SystemPaste
nmap <leader>p <Plug>SystemPaste
nmap <leader>P <Plug>SystemPasteLine
```

System Copy
===========

Expand Down
47 changes: 6 additions & 41 deletions plugin/system_copy.vim
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,10 @@ function! s:system_paste(type, ...) abort
elseif mode == s:visual || mode == s:blockwise
silent exe "normal! `<" . a:type . "`>c" . paste_content
else
silent exe "normal! `[v`]c" . paste_content
let str_len = strcharlen(paste_content)-1
let multiline = strcharpart(paste_content, str_len, 1) == "\n"
let c = [{'p': 'a', 'P': 'i'},{'p': 'o', 'P': 'O'}][multiline]
silent exe "normal! " . c[a:type] . (multiline ? strcharpart(paste_content, 0, str_len) : paste_content)
endif
silent exe "set nopaste"
if g:system_copy_silent == 0
Expand All @@ -70,20 +73,6 @@ function! s:system_paste(type, ...) abort
endif
endfunction

function! s:system_paste_line() abort
let command = <SID>PasteCommandForCurrentOS()
silent let command_output = system(command)
if v:shell_error != 0
echoerr command_output
else
let paste_content = command_output
put =paste_content
if g:system_copy_silent == 0
echohl String | echon 'Pasted to vim using: ' . command | echohl None
endif
endif
endfunction

function! s:resolve_mode(type, arg)
let visual_mode = a:arg != 0
if visual_mode
Expand Down Expand Up @@ -151,30 +140,6 @@ xnoremap <silent> <Plug>SystemCopy :<C-U>call <SID>system_copy(visualmode(),visu
nnoremap <silent> <Plug>SystemCopy :<C-U>set opfunc=<SID>system_copy<CR>g@
nnoremap <silent> <Plug>SystemCopyLine :<C-U>set opfunc=<SID>system_copy<Bar>exe 'norm! 'v:count1.'g@_'<CR>
xnoremap <silent> <Plug>SystemPaste :<C-U>call <SID>system_paste(visualmode(),visualmode() ==# 'V' ? 1 : 0)<CR>
nnoremap <silent> <Plug>SystemPaste :<C-U>set opfunc=<SID>system_paste<CR>g@
nnoremap <silent> <Plug>SystemPasteLine :<C-U>call <SID>system_paste_line()<CR>

if !hasmapto('<Plug>SystemCopy', 'n') || maparg('cp', 'n') ==# ''
nmap cp <Plug>SystemCopy
endif

if !hasmapto('<Plug>SystemCopy', 'v') || maparg('cp', 'v') ==# ''
xmap cp <Plug>SystemCopy
endif

if !hasmapto('<Plug>SystemCopyLine', 'n') || maparg('cP', 'n') ==# ''
nmap cP <Plug>SystemCopyLine
endif

if !hasmapto('<Plug>SystemPaste', 'n') || maparg('cv', 'n') ==# ''
nmap cv <Plug>SystemPaste
endif

if !hasmapto('<Plug>SystemPaste', 'v') || maparg('cv', 'v') ==# ''
xmap cv <Plug>SystemPaste
endif

if !hasmapto('<Plug>SystemPasteLine', 'n') || maparg('cV', 'n') ==# ''
nmap cV <Plug>SystemPasteLine
endif
nnoremap <silent> <Plug>SystemPaste :<C-U>call <SID>system_paste('p')<CR>
nnoremap <silent> <Plug>SystemPasteLine :<C-U>call <SID>system_paste('P')<CR>
" vim:ts=2:sw=2:sts=2