Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Yankround_append at TextYankPost #27

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
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
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ p でテキストの貼り付けを行った後、<C-p><C-n>で貼
`:CtrlPYankRound`コマンドを実行してください。
レジスタ履歴が一覧表示されます。履歴を選択後、

- <CR>で、その履歴をカーソル位置に挿入します。
- <C-x>(<C-s>)で、無名レジスタ " にその履歴をセットします。
- <C-t>で、その履歴を履歴から削除します

- `<CR>`で、その履歴をカーソル位置の前に挿入します。`P`
- `<C-v>`で、その履歴をカーソル位置の後ろに挿入します。`p`
- `<C-s>`(`<C-x>`, `<C-CR>`)で、無名レジスタ `"` にその履歴をセットします
- `<C-z>`でマークして、`<F7>`でその履歴を履歴から削除します。

28 changes: 19 additions & 9 deletions autoload/ctrlp/yankround.vim
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ let s:save_cpo = &cpo| set cpo&vim
"=============================================================================
let s:CTRLP_BUILTINS = ctrlp#getvar('g:ctrlp_builtins')
"======================================
let s:ctrlp_yankround_var = {'lname': 'yankround', 'sname': 'ynkrd', 'typs': 'tabe', 'sort': 0, 'nolim': 1}
let s:ctrlp_yankround_var = {'lname': 'yankround', 'sname': 'ykrd', 'type': 'tabe', 'sort': 0, 'nolim': 1, 'opmul': 1}
let s:ctrlp_yankround_var.init = 'ctrlp#yankround#init()'
let s:ctrlp_yankround_var.accept = 'ctrlp#yankround#accept'
let s:ctrlp_yankround_var.wipe = 'ctrlp#yankround#wipe'
let g:ctrlp_ext_vars = add(get(g:, 'ctrlp_ext_vars', []), s:ctrlp_yankround_var)
unlet s:ctrlp_yankround_var
let s:index_id = s:CTRLP_BUILTINS + len(g:ctrlp_ext_vars)
Expand All @@ -18,23 +19,32 @@ function! ctrlp#yankround#init() "{{{
endfunction
"}}}
function! ctrlp#yankround#accept(action, str) "{{{
if a:action=='t'
return
end
call ctrlp#exit()
let str = a:str
let strlist = map(copy(g:_yankround_cache), 's:_cache_to_ctrlpline(v:val)')
let idx = index(strlist, str)
if a:action=='t'
let removed = remove(g:_yankround_cache, idx)
let @" = @"==#substitute(removed, '^.\d*\t', '', '') ? '' : @"
call ctrlp#init(ctrlp#yankround#id())
return
end
let [str, regtype] = yankround#_get_cache_and_regtype(idx)
call setreg('"', str, regtype)
if a:action!='h'
exe 'norm! ""'. (col('$')-col('.')<=1 ? 'p': 'P')
if a:action=='e'
exe 'norm! P'
elseif a:action=='v'
exe 'norm! p'
end
endfunction
"}}}
function! ctrlp#yankround#wipe(entries) "{{{
let strlist = map(copy(g:_yankround_cache), 's:_cache_to_ctrlpline(v:val)')
for item in a:entries
let idx = index(strlist, item)
let removed = remove(g:_yankround_cache, idx)
endfor
let @" = @"==#substitute(removed, '^.\d*\t', '', '') ? '' : @"
return ctrlp#yankround#init()
endfunction
"}}}
unlet s:CTRLP_BUILTINS

"======================================
Expand Down
7 changes: 4 additions & 3 deletions doc/yankround.jax
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,10 @@ https://github.com/LeafCage/yankround.vim
* ctrlp.vimによる履歴の閲覧 ~
|:CtrlPYankRound|コマンドを実行してください。
レジスタ履歴が一覧表示されます。履歴を選択後、
- <CR>で、その履歴をカーソル位置に挿入します。
- <C-x>(<C-s>)で、無名レジスタ " にその履歴をセットします。
- <C-t>で、その履歴を履歴から削除します。
- <CR>で、その履歴をカーソル位置の前に挿入します。|P|
- <C-v>で、その履歴をカーソル位置の後ろに挿入します。|p|
- <C-s>(<C-x>, <C-CR>)で、無名レジスタ " にその履歴をセットします。
- <C-z>でマークして、<F7>でその履歴を履歴から削除します。


* コマンドライン内での利用 ~
Expand Down
5 changes: 4 additions & 1 deletion plugin/yankround.vim
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ xnoremap <silent><Plug>(yankround-gp) :<C-u>exe yankround#init('gp', 'v')<Bar
xmap <Plug>(yankround-gP) <Plug>(yankround-gp)
nnoremap <silent><Plug>(yankround-prev) :<C-u>call yankround#prev()<CR>
nnoremap <silent><Plug>(yankround-next) :<C-u>call yankround#next()<CR>
cnoremap <Plug>(yankround-insert-register) <C-\>eyankround#cmdline_base()<CR><C-r>
cnoremap <expr><Plug>(yankround-insert-register) getcmdline()=="" ? "\<C-r>" : "\<C-\>eyankround#cmdline_base()\<CR>\<C-r>"
cnoremap <Plug>(yankround-pop) <C-\>eyankround#cmdline_pop(1)<CR>
cnoremap <Plug>(yankround-backpop) <C-\>eyankround#cmdline_pop(-1)<CR>

Expand All @@ -38,6 +38,9 @@ let g:_yankround_stop_caching = 0

aug yankround
autocmd!
if exists('##TextYankPost')
autocmd TextYankPost * call Yankround_append()
endif
autocmd CursorMoved * call Yankround_append()
autocmd ColorScheme * call s:define_region_hl()
autocmd VimLeavePre * call s:_persistent()
Expand Down