Paste from registers
This commit is contained in:
parent
bfbbbafa86
commit
34881d22cd
@ -584,13 +584,18 @@ fu! s:PrtInsert(...)
|
|||||||
let type = s:insertstr()
|
let type = s:insertstr()
|
||||||
if type == 'cancel' | retu | en
|
if type == 'cancel' | retu | en
|
||||||
en
|
en
|
||||||
|
if type ==# 'r'
|
||||||
|
let regcont = s:getregs()
|
||||||
|
if regcont < 0 | retu | en
|
||||||
|
en
|
||||||
unl! s:hstgot
|
unl! s:hstgot
|
||||||
let s:act_add = 1
|
let s:act_add = 1
|
||||||
let s:prompt[0] .= type == 'w' ? s:crword
|
let s:prompt[0] .= type ==# 'w' ? s:crword
|
||||||
\ : type == 's' ? getreg('/')
|
\ : type ==# 'f' ? s:crgfile
|
||||||
\ : type == 'v' ? s:crvisual
|
\ : type ==# 's' ? s:regisfilter('/')
|
||||||
\ : type == 'c' ? substitute(getreg('+'), '\n', '\\n', 'g')
|
\ : type ==# 'v' ? s:crvisual
|
||||||
\ : type == 'f' ? s:crgfile : s:prompt[0]
|
\ : type ==# 'c' ? s:regisfilter('+')
|
||||||
|
\ : type ==# 'r' ? regcont : ''
|
||||||
cal s:BuildPrompt(1)
|
cal s:BuildPrompt(1)
|
||||||
unl s:act_add
|
unl s:act_add
|
||||||
endf
|
endf
|
||||||
@ -1503,16 +1508,17 @@ fu! s:argmaps(md, ...)
|
|||||||
endf
|
endf
|
||||||
|
|
||||||
fu! s:insertstr()
|
fu! s:insertstr()
|
||||||
let str = 'Insert: c[w]ord/c[f]ile/[s]earch/[v]isual/[c]lipboard? '
|
let str = 'Insert: c[w]ord/c[f]ile/[s]earch/[v]isual/[c]lipboard/[r]egister? '
|
||||||
retu s:choices(str, ['w', 'f', 's', 'v', 'c'], 's:insertstr', [])
|
retu s:choices(str, ['w', 'f', 's', 'v', 'c', 'r'], 's:insertstr', [])
|
||||||
|
endf
|
||||||
|
|
||||||
|
fu! s:textdialog(str)
|
||||||
|
redr | echoh MoreMsg | echon a:str | echoh None
|
||||||
|
retu nr2char(getchar())
|
||||||
endf
|
endf
|
||||||
|
|
||||||
fu! s:choices(str, choices, func, args)
|
fu! s:choices(str, choices, func, args)
|
||||||
redr
|
let char = s:textdialog(a:str)
|
||||||
echoh MoreMsg
|
|
||||||
echon a:str
|
|
||||||
echoh None
|
|
||||||
let char = nr2char(getchar())
|
|
||||||
if index(a:choices, char) >= 0
|
if index(a:choices, char) >= 0
|
||||||
retu char
|
retu char
|
||||||
elsei char =~# "\\v\<Esc>|\<C-c>|\<C-g>|\<C-u>|\<C-w>|\<C-[>"
|
elsei char =~# "\\v\<Esc>|\<C-c>|\<C-g>|\<C-u>|\<C-w>|\<C-[>"
|
||||||
@ -1523,6 +1529,21 @@ fu! s:choices(str, choices, func, args)
|
|||||||
en
|
en
|
||||||
retu call(a:func, a:args)
|
retu call(a:func, a:args)
|
||||||
endf
|
endf
|
||||||
|
|
||||||
|
fu! s:getregs()
|
||||||
|
let char = s:textdialog('Insert from register: ')
|
||||||
|
if char =~# "\\v\<Esc>|\<C-c>|\<C-g>|\<C-u>|\<C-w>|\<C-[>"
|
||||||
|
cal s:BuildPrompt(0)
|
||||||
|
retu -1
|
||||||
|
elsei char =~# "\<CR>"
|
||||||
|
retu s:getregs()
|
||||||
|
en
|
||||||
|
retu s:regisfilter(char)
|
||||||
|
endf
|
||||||
|
|
||||||
|
fu! s:regisfilter(reg)
|
||||||
|
retu substitute(getreg(a:reg), "[\t\n]", ' ', 'g')
|
||||||
|
endf
|
||||||
" Misc {{{2
|
" Misc {{{2
|
||||||
fu! s:modevar()
|
fu! s:modevar()
|
||||||
let s:matchtype = s:mtype()
|
let s:matchtype = s:mtype()
|
||||||
@ -1621,7 +1642,7 @@ fu! s:lastvisual()
|
|||||||
let [ovreg, ovtype] = [getreg('v'), getregtype('v')]
|
let [ovreg, ovtype] = [getreg('v'), getregtype('v')]
|
||||||
let [oureg, outype] = [getreg('"'), getregtype('"')]
|
let [oureg, outype] = [getreg('"'), getregtype('"')]
|
||||||
sil! norm! gv"vy
|
sil! norm! gv"vy
|
||||||
let selected = substitute(getreg('v'), '\n', '\\n', 'g')
|
let selected = s:regisfilter('v')
|
||||||
cal setreg('v', ovreg, ovtype)
|
cal setreg('v', ovreg, ovtype)
|
||||||
cal setreg('"', oureg, outype)
|
cal setreg('"', oureg, outype)
|
||||||
cal winrestview(cview)
|
cal winrestview(cview)
|
||||||
|
@ -698,7 +698,8 @@ Pasting:~
|
|||||||
|
|
||||||
<c-\>
|
<c-\>
|
||||||
Open a text dialog to paste <cword>, <cfile>, the content of the search
|
Open a text dialog to paste <cword>, <cfile>, the content of the search
|
||||||
register, the last visual selection or the clipboard into the prompt.
|
register, the last visual selection, the clipboard or any register into the
|
||||||
|
prompt.
|
||||||
|
|
||||||
Choose your own mappings with |g:ctrlp_prompt_mappings|.
|
Choose your own mappings with |g:ctrlp_prompt_mappings|.
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user