diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..926ccaa --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +doc/tags diff --git a/README.md b/README.md index b178210..6ee7179 100644 --- a/README.md +++ b/README.md @@ -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 y SystemCopy +nmap yy SystemCopyLine +nmap Y SystemCopyLine +xmap y SystemCopy +xmap p SystemPaste +nmap p SystemPaste +nmap P SystemPasteLine +``` + System Copy =========== diff --git a/plugin/system_copy.vim b/plugin/system_copy.vim index c234e23..2672d35 100644 --- a/plugin/system_copy.vim +++ b/plugin/system_copy.vim @@ -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 @@ -70,20 +73,6 @@ function! s:system_paste(type, ...) abort endif endfunction -function! s:system_paste_line() abort - let command = 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 @@ -151,30 +140,6 @@ xnoremap SystemCopy :call system_copy(visualmode(),visu nnoremap SystemCopy :set opfunc=system_copyg@ nnoremap SystemCopyLine :set opfunc=system_copyexe 'norm! 'v:count1.'g@_' xnoremap SystemPaste :call system_paste(visualmode(),visualmode() ==# 'V' ? 1 : 0) -nnoremap SystemPaste :set opfunc=system_pasteg@ -nnoremap SystemPasteLine :call system_paste_line() - -if !hasmapto('SystemCopy', 'n') || maparg('cp', 'n') ==# '' - nmap cp SystemCopy -endif - -if !hasmapto('SystemCopy', 'v') || maparg('cp', 'v') ==# '' - xmap cp SystemCopy -endif - -if !hasmapto('SystemCopyLine', 'n') || maparg('cP', 'n') ==# '' - nmap cP SystemCopyLine -endif - -if !hasmapto('SystemPaste', 'n') || maparg('cv', 'n') ==# '' - nmap cv SystemPaste -endif - -if !hasmapto('SystemPaste', 'v') || maparg('cv', 'v') ==# '' - xmap cv SystemPaste -endif - -if !hasmapto('SystemPasteLine', 'n') || maparg('cV', 'n') ==# '' - nmap cV SystemPasteLine -endif +nnoremap SystemPaste :call system_paste('p') +nnoremap SystemPasteLine :call system_paste('P') " vim:ts=2:sw=2:sts=2