One mapping...

...to rule them all, one mapping to find them,
One mapping to bring them all and in the darkness bind them.
This commit is contained in:
Kien N 2012-04-21 08:38:29 +07:00
parent 008ad743e9
commit 5dfe7f245b
2 changed files with 33 additions and 28 deletions

View File

@ -125,11 +125,8 @@ fu! s:opts()
\ 'ToggleType(1)': ['<c-f>', '<c-up>'], \ 'ToggleType(1)': ['<c-f>', '<c-up>'],
\ 'ToggleType(-1)': ['<c-b>', '<c-down>'], \ 'ToggleType(-1)': ['<c-b>', '<c-down>'],
\ 'PrtExpandDir()': ['<tab>'], \ 'PrtExpandDir()': ['<tab>'],
\ 'PrtInsert("w")': ['<F2>', '<insert>'], \ 'PrtInsert("c")': ['<MiddleMouse>', '<insert>'],
\ 'PrtInsert("s")': ['<F3>'], \ 'PrtInsert()': ['<c-\>'],
\ 'PrtInsert("v")': ['<F4>'],
\ 'PrtInsert("+")': ['<F6>', '<MiddleMouse>'],
\ 'PrtInsert("gf")': ['<c-\>'],
\ 'PrtCurStart()': ['<c-a>'], \ 'PrtCurStart()': ['<c-a>'],
\ 'PrtCurEnd()': ['<c-e>'], \ 'PrtCurEnd()': ['<c-e>'],
\ 'PrtCurLeft()': ['<c-h>', '<left>', '<c-^>'], \ 'PrtCurLeft()': ['<c-h>', '<left>', '<c-^>'],
@ -183,11 +180,8 @@ let s:prtunmaps = [
\ 'PrtCurRight()', \ 'PrtCurRight()',
\ 'PrtHistory(-1)', \ 'PrtHistory(-1)',
\ 'PrtHistory(1)', \ 'PrtHistory(1)',
\ 'PrtInsert("w")', \ 'PrtInsert("c")',
\ 'PrtInsert("s")', \ 'PrtInsert()',
\ 'PrtInsert("v")',
\ 'PrtInsert("+")',
\ 'PrtInsert("gf")',
\ ] \ ]
" Keypad " Keypad
@ -555,14 +549,19 @@ fu! s:PrtDeleteWord()
cal s:BuildPrompt(1) cal s:BuildPrompt(1)
endf endf
fu! s:PrtInsert(type) fu! s:PrtInsert(...)
let type = !a:0 ? '' : a:1
if !a:0
let type = s:insertstr()
if type == 'cancel' | retu | en
en
unl! s:hstgot unl! s:hstgot
let s:act_add = 1 let s:act_add = 1
let s:prompt[0] .= a:type == 'w' ? s:crword let s:prompt[0] .= type == 'w' ? s:crword
\ : a:type == 's' ? getreg('/') \ : type == 's' ? getreg('/')
\ : a:type == 'v' ? s:crvisual \ : type == 'v' ? s:crvisual
\ : a:type == '+' ? substitute(getreg('+'), '\n', '\\n', 'g') \ : type == 'c' ? substitute(getreg('+'), '\n', '\\n', 'g')
\ : a:type == 'gf' ? s:crgfile : s:prompt[0] \ : type == 'f' ? s:crgfile : s:prompt[0]
cal s:BuildPrompt(1) cal s:BuildPrompt(1)
unl s:act_add unl s:act_add
endf endf
@ -1437,18 +1436,29 @@ fu! s:sanstail(str)
endf endf
fu! s:argmaps(md, ...) fu! s:argmaps(md, ...)
let str = '[t]ab/[v]ertical/[h]orizontal'.( a:0 ? '/[r]eplace' : '' ).'? '
let args = [a:md] + ( a:0 ? [a:1] : [] )
retu s:choices(str, ['r', 'h', 't', 'v'], 's:argmaps', args)
endf
fu! s:insertstr()
let str = 'Insert: c[w]ord/c[f]ile/[s]earch/[v]isual/[c]lipboard? '
retu s:choices(str, ['w', 'f', 's', 'v', 'c'], 's:insertstr', [])
endf
fu! s:choices(str, choices, func, args)
redr redr
echoh MoreMsg echoh MoreMsg
echon '[t]ab/[v]ertical/[h]orizontal'.( a:0 ? '/[r]eplace' : '' ).'? ' echon a:str
echoh None echoh None
let char = nr2char(getchar()) let char = nr2char(getchar())
if index(['r', 'h', 't', 'v'], char) >= 0 if index(a:choices, char) >= 0
retu char retu char
elsei char =~# "\\v\<Esc>|\<C-c>|\<C-[>" elsei char =~# "\\v\<Esc>|\<C-c>|\<C-g>|\<C-u>|\<C-w>|\<C-[>"
cal s:BuildPrompt(0) cal s:BuildPrompt(0)
retu 'cancel' retu 'cancel'
en en
retu a:md retu call(a:func, a:args)
endf endf
" Misc {{{2 " Misc {{{2
fu! s:modevar() fu! s:modevar()

View File

@ -312,9 +312,7 @@ Pressing <c-o> or <c-y> will then prompt for a keypress. The key can be:
h - open in horizontal split(s) h - open in horizontal split(s)
v - open in vertical split(s) v - open in vertical split(s)
r - open in current window (for <c-y> only) r - open in current window (for <c-y> only)
<esc>, <c-c> - cancel and go back to the prompt. <esc>, <c-c>, <c-g> - cancel and go back to the prompt.
Any other key - use the behavior specified with |g:ctrlp_open_new_file| and
|g:ctrlp_open_multiple_files|.
*'g:ctrlp_follow_symlinks'* *'g:ctrlp_follow_symlinks'*
Set this to 1 to follow symbolic links when listing files: > Set this to 1 to follow symbolic links when listing files: >
@ -368,11 +366,8 @@ only need to keep the lines that youve changed the values (inside []): >
\ 'ToggleType(1)': ['<c-f>', '<c-up>'], \ 'ToggleType(1)': ['<c-f>', '<c-up>'],
\ 'ToggleType(-1)': ['<c-b>', '<c-down>'], \ 'ToggleType(-1)': ['<c-b>', '<c-down>'],
\ 'PrtExpandDir()': ['<tab>'], \ 'PrtExpandDir()': ['<tab>'],
\ 'PrtInsert("w")': ['<F2>', '<insert>'], \ 'PrtInsert("c")': ['<MiddleMouse>', '<insert>'],
\ 'PrtInsert("s")': ['<F3>'], \ 'PrtInsert()': ['<c-\>'],
\ 'PrtInsert("v")': ['<F4>'],
\ 'PrtInsert("+")': ['<F6>', '<MiddleMouse>'],
\ 'PrtInsert("gf")': ['<c-\>'],
\ 'PrtCurStart()': ['<c-a>'], \ 'PrtCurStart()': ['<c-a>'],
\ 'PrtCurEnd()': ['<c-e>'], \ 'PrtCurEnd()': ['<c-e>'],
\ 'PrtCurLeft()': ['<c-h>', '<left>', '<c-^>'], \ 'PrtCurLeft()': ['<c-h>', '<left>', '<c-^>'],