Skip to content

Instantly share code, notes, and snippets.

@hokaccha
Created October 4, 2009 09:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hokaccha/201280 to your computer and use it in GitHub Desktop.
Save hokaccha/201280 to your computer and use it in GitHub Desktop.
" Macでクリップボードにコピーするoperator
if has('mac')
function! Pbcopy(type, ...)
let reg_save = @@
if a:0
silent execute "normal! `<" . a:type . "`>y"
elseif a:type == 'line'
silent execute "normal! '[V']y"
elseif a:type == 'block'
silent execute "normal! `[\<C-V>`]y"
else
silent execute "normal! `[v`]y"
endif
call system('iconv -f utf-8 -t shift-jis | pbcopy', @@)
let @@ = reg_save
endfunction
nnoremap <silent> <Space>y :<C-u>set opfunc=Pbcopy<CR>g@
nnoremap <silent> <Space>yy :<C-u>set opfunc=Pbcopy<CR>g@g@
vnoremap <silent> <Space>y :<C-u>call Pbcopy(visualmode(), 1)<CR>
nnoremap <silent> <Space>p :<C-u>r !pbpaste<CR>
endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment