Commits

kien  committed 24d52d8 Draft

Input abbreviations [...]

Escape cmd.exe reserved chars
Support typing multi-byte and accented characters
Support using a one-time value for some options
Rename g:ctrlp_dotfiles and change its default value
Add b:var support for some options
Save the current cursor position before jumping
Also split if the buffer isn't writable
Make LastMode also be able to restore last working directory
Change working_path_mode's default

  • Participants
  • Parent commits 1b2da8e

Comments (0)

Files changed (6)

File autoload/ctrlp.vim

 " =============================================================================
 
 " ** Static variables {{{1
-fu! s:ignore() "{{{2
+" s:ignore() {{{2
+fu! s:ignore()
 	let igdirs = [
 		\ '\.git',
 		\ '\.hg',
 		\ 'dir': '\v[\/]('.join(igdirs, '|').')$',
 		\ 'file': '\v'.join(igfiles, '|'),
 		\ }
-endf "}}}2
-" Options
-let [s:pref, s:opts, s:new_opts] = ['g:ctrlp_', {
+endf
+" Script local vars {{{2
+let [s:pref, s:bpref, s:opts, s:new_opts, s:lc_opts] =
+	\ ['g:ctrlp_', 'b:ctrlp_', {
+	\ 'abbrev':                ['s:abbrev', {}],
 	\ 'arg_map':               ['s:argmap', 0],
 	\ 'buffer_func':           ['s:buffunc', {}],
 	\ 'by_filename':           ['s:byfname', 0],
 	\ 'custom_ignore':         ['s:usrign', s:ignore()],
 	\ 'default_input':         ['s:deftxt', 0],
 	\ 'dont_split':            ['s:nosplit', 'netrw'],
-	\ 'dotfiles':              ['s:dotfiles', 1],
+	\ 'dotfiles':              ['s:showhidden', 0],
 	\ 'extensions':            ['s:extensions', []],
 	\ 'follow_symlinks':       ['s:folsym', 0],
 	\ 'highlight_match':       ['s:mathi', [1, 'CtrlPMatch']],
 	\ 'jump_to_buffer':        ['s:jmptobuf', 'Et'],
+	\ 'key_loop':              ['s:keyloop', 0],
 	\ 'lazy_update':           ['s:lazy', 0],
 	\ 'match_func':            ['s:matcher', {}],
 	\ 'match_window_bottom':   ['s:mwbottom', 1],
 	\ 'use_caching':           ['s:caching', 1],
 	\ 'use_migemo':            ['s:migemo', 0],
 	\ 'user_command':          ['s:usrcmd', ''],
-	\ 'working_path_mode':     ['s:pathmode', 'rc'],
+	\ 'working_path_mode':     ['s:pathmode', 'ra'],
 	\ }, {
 	\ 'open_multiple_files':   's:opmul',
 	\ 'regexp':                's:regexp',
 	\ 'reuse_window':          's:nosplit',
+	\ 'show_hidden':           's:showhidden',
 	\ 'switch_buffer':         's:jmptobuf',
+	\ }, {
+	\ 'root_markers':          's:rmarkers',
+	\ 'user_command':          's:usrcmd',
+	\ 'working_path_mode':     's:pathmode',
 	\ }]
 
 " Global options
 	\ 'PrtText': 'Normal',
 	\ 'PrtCursor': 'Constant',
 	\ }
-
-fu! s:opts() "{{{2
-	" Options
+" s:opts() {{{2
+fu! s:opts(...)
 	unl! s:usrign s:usrcmd s:urprtmaps
 	for each in ['byfname', 'regexp', 'extensions'] | if exists('s:'.each)
 		let {each} = s:{each}
 	for [ke, va] in items(s:new_opts)
 		let {va} = {exists(s:pref.ke) ? s:pref.ke : va}
 	endfo
+	unl va
+	for [ke, va] in items(s:lc_opts)
+		if exists(s:bpref.ke)
+			unl {va}
+			let {va} = {s:bpref.ke}
+		en
+	endfo
+	if a:0 && a:1 != {}
+		unl va
+		for [ke, va] in items(a:1)
+			let opke = substitute(ke, '\(\w:\)\?ctrlp_', '', '')
+			if has_key(s:lc_opts, opke)
+				let sva = s:lc_opts[opke]
+				unl {sva}
+				let {sva} = va
+			en
+		endfo
+	en
 	for each in ['byfname', 'regexp'] | if exists(each)
 		let s:{each} = {each}
 	en | endfo
 	if !exists('g:ctrlp_newcache') | let g:ctrlp_newcache = 0 | en
 	let s:maxdepth = min([s:maxdepth, 100])
 	let s:mxheight = max([s:mxheight, 1])
-	let s:glob = s:dotfiles ? '.*\|*' : '*'
+	let s:glob = s:showhidden ? '.*\|*' : '*'
 	let s:igntype = empty(s:usrign) ? -1 : type(s:usrign)
+	if s:keyloop
+		let [s:lazy, s:glbs['imd']] = [0, 0]
+	en
 	if s:lazy
 		cal extend(s:glbs, { 'ut': ( s:lazy > 1 ? s:lazy : 250 ) })
 	en
 "}}}1
 " * Open & Close {{{1
 fu! s:Open()
-	let s:ermsg = v:errmsg
 	cal s:log(1)
 	cal s:getenv()
 	cal s:execextvar('enter')
 		exe s:winres[0]
 	en
 	unl! s:focus s:hisidx s:hstgot s:marked s:statypes s:cline s:init s:savestr
-		\ s:mrbs
+		\ s:mrbs s:did_exp
 	cal ctrlp#recordhist()
 	cal s:execextvar('exit')
 	cal s:log(0)
 	cal ctrlp#clr()
 endf
 
-fu! ctrlp#reset()
-	cal s:opts()
+fu! s:Reset(args)
+	let opts = has_key(a:args, 'opts') ? [a:args['opts']] : []
+	cal call('s:opts', opts)
 	cal s:autocmds()
 	cal ctrlp#utils#opts()
 	cal s:execextvar('opts')
 " * MatchedItems() {{{1
 fu! s:MatchIt(items, pat, limit, exc)
 	let [lines, id] = [[], 0]
-	let pat = s:byfname ?
-		\ map(split(a:pat, '^[^;]\+\zs;', 1), 's:martcs.v:val') : s:martcs.a:pat
+	let pat =
+		\ s:byfname ? map(split(a:pat, '^[^;]\+\\\@<!\zs;', 1), 's:martcs.v:val')
+		\ : s:martcs.a:pat
 	for item in a:items
 		let id += 1
 		try | if !( s:ispath && item == a:exc ) && call(s:mfunc, [item, pat]) >= 0
 		let lines = s:MatchIt(items, a:pat, a:limit, exc)
 	en
 	let s:matches = len(lines)
+	unl! s:did_exp
 	retu lines
 endf
 
 " * BuildPrompt() {{{1
 fu! s:Render(lines, pat)
 	let [&ma, lines, s:height] = [1, a:lines, min([len(a:lines), s:winh])]
-	let pat = s:byfname ? split(a:pat, '^[^;]\+\zs;', 1)[0] : a:pat
+	let pat = s:byfname ? split(a:pat, '^[^;]\+\\\@<!\zs;', 1)[0] : a:pat
 	" Setup the match window
 	sil! exe '%d _ | res' s:height
 	" Print the new items
 endf
 
 fu! s:ForceUpdate()
-	let [estr, prt] = ['"\', copy(s:prompt)]
-	cal map(prt, 'escape(v:val, estr)')
-	sil! cal s:Update(join(prt, ''))
+	sil! cal s:Update(escape(s:getinput(), '\'))
 endf
 
 fu! s:BuildPrompt(upd)
 	let base = ( s:regexp ? 'r' : '>' ).( s:byfname ? 'd' : '>' ).'> '
-	let [estr, prt] = ['"\', copy(s:prompt)]
-	cal map(prt, 'escape(v:val, estr)')
-	let str = join(prt, '')
-	let lazy = empty(str) || exists('s:force') || !has('autocmd') ? 0 : s:lazy
-	if a:upd && !lazy && ( s:matches || s:regexp
+	let str = escape(s:getinput(), '\')
+	let lazy = str == '' || exists('s:force') || !has('autocmd') ? 0 : s:lazy
+	if a:upd && !lazy && ( s:matches || s:regexp || exists('s:did_exp')
 		\ || str =~ '\(\\\(<\|>\)\|[*|]\)\|\(\\\:\([^:]\|\\:\)*$\)' )
 		sil! cal s:Update(str)
 	en
 	let hibase = 'CtrlPPrtBase'
 	" Build it
 	redr
+	let prt = copy(s:prompt)
+	cal map(prt, 'escape(v:val, ''"\'')')
 	exe 'echoh' hibase '| echon "'.base.'"
 		\ | echoh' hiactive '| echon "'.prt[0].'"
 		\ | echoh' hicursor '| echon "'.prt[1].'"
 
 fu! s:PrtExpandDir()
 	if !s:focus | retu | en
-	let str = s:prompt[0]
+	let str = s:getinput('c')
 	if str =~ '\v^\@(cd|lc[hd]?|chd)\s.+' && s:spi
 		let hasat = split(str, '\v^\@(cd|lc[hd]?|chd)\s*\zs')
 		let str = get(hasat, 1, '')
 			let npos = match(lines, smartcs.'^'.chr, s:jmpchr[1] + 1)
 			let [jmpln, s:jmpchr] = [npos == -1 ? pos : npos, [chr, npos]]
 		en
-		keepj exe jmpln + 1
+		exe 'keepj norm!' ( jmpln + 1 ).'G'
 		if s:nolim != 1 | let s:cline = line('.') | en
 		if line('$') > winheight(0) | cal s:BuildPrompt(0) | en
 	en
 	let cmd = substitute(pcmd, 'k%s', 'char-%d', '')
 	let pfunc = 'PrtFocusMap'
 	let ranges = [32, 33, 125, 126] + range(35, 91) + range(93, 123)
-		\ + range(128, 255)
 	for each in [34, 92, 124]
 		exe printf(cmd, each, pfunc, escape(nr2char(each), '"|\'))
 	endfo
 	endfo | endfo
 	let s:smapped = s:bufnr
 endf
+
+fu! s:KeyLoop()
+	wh exists('s:init') && s:keyloop
+		redr
+		let nr = getchar()
+		let chr = !type(nr) ? nr2char(nr) : nr
+		if nr >=# 0x20
+			cal s:PrtFocusMap(chr)
+		el
+			let cmd = matchstr(maparg(chr), ':<C-U>\zs.\+\ze<CR>$')
+			exe ( cmd != '' ? cmd : 'norm '.chr )
+		en
+	endw
+endf
 " * Toggling {{{1
 fu! s:ToggleFocus()
-	let s:focus = s:focus ? 0 : 1
+	let s:focus = !s:focus
 	cal s:BuildPrompt(0)
 endf
 
 fu! s:ToggleRegex()
-	let s:regexp = s:regexp ? 0 : 1
+	let s:regexp = !s:regexp
 	cal s:PrtSwitcher()
 endf
 
 fu! s:ToggleByFname()
 	if s:ispath
-		let s:byfname = s:byfname ? 0 : 1
+		let s:byfname = !s:byfname
 		let s:mfunc = s:mfunc()
 		cal s:PrtSwitcher()
 	en
 	cal s:PrtSwitcher()
 endf
 
+fu! s:ToggleKeyLoop()
+	let s:keyloop = !s:keyloop
+	if s:keyloop
+		let [&ut, s:lazy] = [0, 0]
+		cal s:KeyLoop()
+	elsei has_key(s:glbs, 'ut')
+		let [&ut, s:lazy] = [s:glbs['ut'], 1]
+	en
+endf
+
 fu! s:PrtSwitcher()
 	let [s:force, s:matches] = [1, 1]
 	cal s:BuildPrompt(1)
 endf
 " - SetWD() {{{1
 fu! s:SetWD(args)
-	let [s:crfilerel, s:dyncwd] = [fnamemodify(s:crfile, ':.'), getcwd()]
-	let pmode = has_key(a:args, 'mode') ? a:args['mode'] : s:wpmode
+	if has_key(a:args, 'args') && stridx(a:args['args'], '--dir') >= 0
+		\ && exists('s:dyncwd')
+		cal ctrlp#setdir(s:dyncwd) | retu
+	en
 	if has_key(a:args, 'dir') && a:args['dir'] != ''
 		cal ctrlp#setdir(a:args['dir']) | retu
 	en
+	let pmode = has_key(a:args, 'mode') ? a:args['mode'] : s:pathmode
+	let [s:crfilerel, s:dyncwd] = [fnamemodify(s:crfile, ':.'), getcwd()]
 	if s:crfile =~ '^.\+://' | retu | en
-	if pmode =~ 'c' || ( !type(pmode) && pmode )
+	if pmode =~ 'c' || ( pmode =~ 'a' && stridx(s:crfpath, s:cwd) < 0 )
+		\ || ( !type(pmode) && pmode )
 		if exists('+acd') | let [s:glb_acd, &acd] = [&acd, 0] | en
 		cal ctrlp#setdir(s:crfpath)
 	en
 	let [md, filpath] = [a:mode, fnamemodify(a:line, ':p')]
 	cal s:PrtExit()
 	let [bufnr, tail] = [bufnr('^'.filpath.'$'), s:tail()]
-	let j2l = a:0 ? a:1 : str2nr(matchstr(tail, '^ +\D*\zs\d\+\ze\D*'))
+	let j2l = a:0 ? a:1 : matchstr(tail, '^ +\zs\d\+$')
 	if ( s:jmptobuf =~ md || ( s:jmptobuf && md =~ '[et]' ) ) && bufnr > 0
 		\ && !( md == 'e' && bufnr == bufnr('%') )
 		let [jmpb, bufwinnr] = [1, bufwinnr(bufnr)]
 
 fu! s:AcceptSelection(mode)
 	if a:mode != 'e' && s:OpenMulti(a:mode) != -1 | retu | en
-	let str = join(s:prompt, '')
+	let str = s:getinput()
 	if a:mode == 'e' | if s:SpecInputs(str) | retu | en | en
 	" Get the selected line
 	let line = ctrlp#getcline()
 endf
 " - CreateNewFile() {{{1
 fu! s:CreateNewFile(...)
-	let [md, str] = ['', join(s:prompt, '')]
+	let [md, str] = ['', s:getinput('n')]
 	if empty(str) | retu | en
 	if s:argmap && !a:0
 		" Get the extra argument
 		let etype = getftype(each)
 		if s:igntype >= 0 && s:usrign(each, etype) | con | en
 		if etype == 'dir'
-			if s:dotfiles | if each !~ '[\/]\.\{1,2}$'
+			if s:showhidden | if each !~ '[\/]\.\{1,2}$'
 				cal add(items[0], each)
 			en | el
 				cal add(items[0], each)
 	retu a:0 ? a:1 : 'bo vne'
 endf
 
-fu! ctrlp#modfilecond()
-	retu &mod && !&hid && &bh != 'hide' && !&cf && !&awa
-		\ && s:bufwins(bufnr('%')) == 1
+fu! ctrlp#modfilecond(w)
+	retu &mod && !&hid && &bh != 'hide' && s:bufwins(bufnr('%')) == 1 && !&cf &&
+		\ ( ( !&awa && a:w ) || filewritable(fnamemodify(bufname('%'), ':p')) != 1 )
 endf
 
 fu! s:nosplit()
 fu! s:narrowable()
 	retu exists('s:act_add') && exists('s:matched') && s:matched != []
 		\ && exists('s:mdata') && s:mdata[:2] == [s:dyncwd, s:itemtype, s:regexp]
-		\ && s:matcher == {}
+		\ && s:matcher == {} && !exists('s:did_exp')
+endf
+
+fu! s:getinput(...)
+	let [prt, spi] = [s:prompt, ( a:0 ? a:1 : '' )]
+	if s:abbrev != {}
+		let gmd = has_key(s:abbrev, 'gmode') ? s:abbrev['gmode'] : ''
+		let [ayt, nkw] = [( gmd =~ 't' ), ( gmd =~ 'k' )]
+		let str = ( ayt && !a:0 ) || spi == 'c' ? prt[0] : join(prt, '')
+		if ayt && nkw && !a:0 && matchstr(str, '.$') =~ '\k'
+			retu join(prt, '')
+		en
+		let [pf, rz] = [( s:byfname ? 'f' : 'p' ), ( s:regexp ? 'r' : 'z' )]
+		for dict in s:abbrev['abbrevs']
+			let dmd = has_key(dict, 'mode') ? dict['mode'] : ''
+			let pat = escape(dict['pattern'], '~')
+			if ( dmd == '' || ( dmd =~ pf && dmd =~ rz && !a:0 )
+				\ || dmd =~ '['.spi.']' ) && str =~ pat
+				let [str, s:did_exp] = [join(split(str, pat, 1), dict['expanded']), 1]
+			en
+		endfo
+		if ayt && !a:0
+			let prt[0] = str
+		el
+			retu str
+		en
+	en
+	retu spi == 'c' ? prt[0] : join(prt, '')
 endf
 
 fu! s:migemo(str)
 endf
 
 fu! ctrlp#j2l(nr)
-	exe a:nr
+	exe 'norm!' a:nr.'G'
 	sil! norm! zvzz
 endf
 
 	let [s:crword, s:crline] = [expand('<cword>', 1), getline('.')]
 	let [s:winh, s:crcursor] = [min([s:mxheight, &lines]), getpos('.')]
 	let [s:crbufnr, s:crvisual] = [bufnr('%'), s:lastvisual()]
-	let s:wpmode = exists('b:ctrlp_working_path_mode')
-		\ ? b:ctrlp_working_path_mode : s:pathmode
 	let [s:mrbs, s:crgfile] = [ctrlp#mrufiles#bufs(), expand('<cfile>', 1)]
 endf
 
 endf
 
 fu! s:openfile(cmd, fid, tail, chkmod, ...)
-	let cmd = a:chkmod && a:cmd =~ '^[eb]$' && ctrlp#modfilecond()
-		\ && !( a:cmd == 'b' && &aw ) ? ( a:cmd == 'b' ? 'sb' : 'sp' ) : a:cmd
+	let cmd = a:cmd
+	if a:chkmod && cmd =~ '^[eb]$' && ctrlp#modfilecond(!( cmd == 'b' && &aw ))
+		let cmd = cmd == 'b' ? 'sb' : 'sp'
+	en
 	let cmd = cmd =~ '^tab' ? ctrlp#tabcount().cmd : cmd
 	let j2l = a:0 && a:1[0] ? a:1[1] : 0
 	exe cmd.( a:0 && a:1[0] ? '' : a:tail ) ctrlp#fnesc(a:fid)
 	if j2l
-		exe j2l
+		cal ctrlp#j2l(j2l)
 	en
-	if !empty(a:tail) || j2l
+	if !empty(a:tail)
 		sil! norm! zvzz
 	en
 	if cmd != 'bad'
 
 fu! ctrlp#init(type, ...)
 	if exists('s:init') || s:iscmdwin() | retu | en
+	let [s:ermsg, v:errmsg] = [v:errmsg, '']
 	let [s:matches, s:init] = [1, 1]
-	cal ctrlp#reset()
+	cal s:Reset(a:0 ? a:1 : {})
 	noa cal s:Open()
 	cal s:SetWD(a:0 ? a:1 : {})
 	cal s:MapNorms()
 	cal ctrlp#setlines(s:settype(a:type))
 	cal s:SetDefTxt()
 	cal s:BuildPrompt(1)
+	if s:keyloop | cal s:KeyLoop() | en
 endf
 " - Autocmds {{{1
 if has('autocmd')

File autoload/ctrlp/buffertag.vim

 	if exists('+ssl')
 		let [ssl, &ssl] = [&ssl, 0]
 	en
-	let fname = a:0 == 1 ? shellescape(a:1) : ''
+	let fname = a:0 ? shellescape(a:1) : ''
 	let cmd = shellescape(a:bin).' '.a:args.' '.fname
+	if &sh =~ 'cmd\.exe'
+		let cmd = substitute(cmd, '[&()@^<>|]', '^\0', 'g')
+	en
 	if exists('+ssl')
 		let &ssl = ssl
 	en
 endf
 
 fu! s:parseline(line)
-	let eval = '\v^([^\t]+)\t(.+)\t[?/]\^?(.{-1,})\$?[?/]\;\"\t(.+)\tline(no)?\:(\d+)'
-	let vals = matchlist(a:line, eval)
+	let vals = matchlist(a:line,
+		\ '\v^([^\t]+)\t(.+)\t[?/]\^?(.{-1,})\$?[?/]\;\"\t(.+)\tline(no)?\:(\d+)')
 	if vals == [] | retu '' | en
 	let [bufnr, bufname] = [bufnr('^'.vals[2].'$'), fnamemodify(vals[2], ':p:t')]
 	retu vals[1].'	'.vals[4].'|'.bufnr.':'.bufname.'|'.vals[6].'| '.vals[3]
 endf
 
 fu! ctrlp#buffertag#accept(mode, str)
-	let vals = matchlist(a:str, '\v^[^\t]+\t+[^\t|]+\|(\d+)\:[^\t|]+\|(\d+)\|')
+	let vals = matchlist(a:str,
+		\ '\v^[^\t]+\t+[^\t|]+\|(\d+)\:[^\t|]+\|(\d+)\|\s(.+)$')
 	let bufnr = str2nr(get(vals, 1))
 	if bufnr
-		cal ctrlp#acceptfile(a:mode, bufname(bufnr), get(vals, 2))
+		cal ctrlp#acceptfile(a:mode, bufname(bufnr))
+		let pat = get(vals, 3, '')
+		exe 'norm!' str2nr(get(vals, 2, line('.'))).'G'
+		if match(getline('.'), pat) < 0
+			let [int, forw, maxl] = [1, 1, line('$')]
+			wh !search(pat, 'W'.( forw ? '' : 'b' ))
+				if !forw
+					if int > maxl | brea | en
+					let int += int
+				en
+				let forw = !forw
+			endw
+		en
+		sil! norm! zvzz
 	en
 endf
 

File autoload/ctrlp/quickfix.vim

 endf
 
 fu! ctrlp#quickfix#accept(mode, str)
-	let items = matchlist(a:str, '^\([^|]\+\ze\)|\(\d\+\):\(\d\+\)|')
-	if items == [] | retu | en
-	let [md, filpath] = [a:mode, fnamemodify(items[1], ':p')]
-	if empty(filpath) | retu | en
-	cal ctrlp#exit()
-	let cmd = md == 't' ? 'tabe' : md == 'h' ? 'new' : md == 'v' ? 'vne'
-		\ : ctrlp#normcmd('e')
-	let cmd = cmd == 'e' && ctrlp#modfilecond() ? 'new' : cmd
-	exe cmd ctrlp#fnesc(filpath)
-	cal cursor(items[2], items[3])
+	let vals = matchlist(a:str, '^\([^|]\+\ze\)|\(\d\+\):\(\d\+\)|')
+	if vals == [] || vals[1] == '' | retu | en
+	cal ctrlp#acceptfile(a:mode, vals[1])
+	let cur_pos = getpos('.')[1:2]
+	if cur_pos != [1, 1] && cur_pos != map(vals[2:3], 'str2nr(v:val)')
+		mark '
+	en
+	cal cursor(vals[2], vals[3])
 	sil! norm! zvzz
-	cal ctrlp#setlcdir()
 endf
 
 fu! ctrlp#quickfix#id()

File autoload/ctrlp/tag.vim

 		\ 'e': ['', 'tj'],
 		\ }
 	let cmd = fnd[0] == 1 ? cmds[a:mode][0] : cmds[a:mode][1]
-	let cmd = a:mode == 'e' && ctrlp#modfilecond() && !&aw
+	let cmd = a:mode == 'e' && ctrlp#modfilecond(!&aw)
 		\ ? ( cmd == 'tj' ? 'stj' : 'sp' ) : cmd
 	let cmd = a:mode == 't' ? ctrlp#tabcount().cmd : cmd
 	if fnd[0] == 1

File doc/ctrlp.txt

 
 Overview:~
 
-  |loaded_ctrlp|                Disable the plugin.
-  |ctrlp_map|                   Default mapping.
-  |ctrlp_cmd|                   Default command used for the default mapping.
-  |ctrlp_by_filename|           Default to filename mode or not.
-  |ctrlp_regexp|                Default to regexp mode or not.
-  |ctrlp_match_window_bottom|   Where to show the match window.
-  |ctrlp_match_window_reversed| Sort order in the match window.
-  |ctrlp_max_height|            Max height of the match window.
-  |ctrlp_switch_buffer|         Jump to an open buffer if already opened.
-  |ctrlp_reuse_window|          Reuse special windows (help, quickfix, etc).
-  |ctrlp_tabpage_position|      Where to put the new tab page.
-  |ctrlp_working_path_mode|     How to set CtrlP's local working directory.
-  |ctrlp_root_markers|          Additional, high priority root markers.
-  |ctrlp_use_caching|           Use per-session caching or not.
-  |ctrlp_clear_cache_on_exit|   Keep cache after exiting Vim or not.
-  |ctrlp_cache_dir|             Location of the cache directory.
-  |ctrlp_dotfiles|              Ignore dotfiles and dotdirs or not.
-  |ctrlp_custom_ignore|         Hide stuff when using |globpath()|.
-  |ctrlp_max_files|             Number of files to scan initially.
-  |ctrlp_max_depth|             Directory depth to recurse into when scanning.
-  |ctrlp_user_command|          Use an external scanner.
-  |ctrlp_max_history|           Number of entries saved in the prompt history.
-  |ctrlp_open_new_file|         How to open a file created by <c-y>.
-  |ctrlp_open_multiple_files|   How to open files selected by <c-z>.
-  |ctrlp_arg_map|               Intercept <c-y> and <c-o> or not.
-  |ctrlp_follow_symlinks|       Follow symbolic links or not.
-  |ctrlp_lazy_update|           Only update when typing has stopped.
-  |ctrlp_default_input|         Seed the prompt with an initial string.
-  |ctrlp_use_migemo|            Use Migemo patterns for Japanese filenames.
-  |ctrlp_prompt_mappings|       Change the mappings in the prompt.
+  |loaded_ctrlp|................Disable the plugin.
+  |ctrlp_map|...................Default mapping.
+  |ctrlp_cmd|...................Default command used for the default mapping.
+  |ctrlp_by_filename|...........Default to filename mode or not.
+  |ctrlp_regexp|................Default to regexp mode or not.
+  |ctrlp_match_window_bottom|...Where to show the match window.
+  |ctrlp_match_window_reversed|.Sort order in the match window.
+  |ctrlp_max_height|............Max height of the match window.
+  |ctrlp_switch_buffer|.........Jump to an open buffer if already opened.
+  |ctrlp_reuse_window|..........Reuse special windows (help, quickfix, etc).
+  |ctrlp_tabpage_position|......Where to put the new tab page.
+  |ctrlp_working_path_mode|.....How to set CtrlP's local working directory.
+  |ctrlp_root_markers|..........Additional, high priority root markers.
+  |ctrlp_use_caching|...........Use per-session caching or not.
+  |ctrlp_clear_cache_on_exit|...Keep cache after exiting Vim or not.
+  |ctrlp_cache_dir|.............Location of the cache directory.
+  |ctrlp_show_hidden|...........Ignore dotfiles and dotdirs or not.
+  |ctrlp_custom_ignore|.........Hide stuff when using |globpath()|.
+  |ctrlp_max_files|.............Number of files to scan initially.
+  |ctrlp_max_depth|.............Directory depth to recurse into when scanning.
+  |ctrlp_user_command|..........Use an external scanner.
+  |ctrlp_max_history|...........Number of entries saved in the prompt history.
+  |ctrlp_open_new_file|.........How to open a file created by <c-y>.
+  |ctrlp_open_multiple_files|...How to open files selected by <c-z>.
+  |ctrlp_arg_map|...............Intercept <c-y> and <c-o> or not.
+  |ctrlp_follow_symlinks|.......Follow symbolic links or not.
+  |ctrlp_lazy_update|...........Only update when typing has stopped.
+  |ctrlp_default_input|.........Seed the prompt with an initial string.
+  |ctrlp_abbrev|................Input abbreviations.
+  |ctrlp_key_loop|..............Use input looping for multi-byte input.
+  |ctrlp_use_migemo|............Use Migemo patterns for Japanese filenames.
+  |ctrlp_prompt_mappings|.......Change the mappings inside the prompt.
 
   MRU mode:
-  |ctrlp_mruf_max|              Max MRU entries to remember.
-  |ctrlp_mruf_exclude|          Files that shouldn't be remembered.
-  |ctrlp_mruf_include|          Files to be remembered.
-  |ctrlp_mruf_relative|         Show only MRU files in the working directory.
-  |ctrlp_mruf_default_order|    Disable sorting.
-  |ctrlp_mruf_case_sensitive|   MRU files are case sensitive or not.
+  |ctrlp_mruf_max|..............Max MRU entries to remember.
+  |ctrlp_mruf_exclude|..........Files that shouldn't be remembered.
+  |ctrlp_mruf_include|..........Files to be remembered.
+  |ctrlp_mruf_relative|.........Show only MRU files in the working directory.
+  |ctrlp_mruf_default_order|....Disable sorting.
+  |ctrlp_mruf_case_sensitive|...MRU files are case sensitive or not.
 
   Advanced options:
-  |ctrlp_open_func|             Use custom file opening functions.
-  |ctrlp_status_func|           Change CtrlP's two statuslines.
-  |ctrlp_buffer_func|           Call custom functions in the CtrlP buffer.
-  |ctrlp_match_func|            Replace the built-in matching algorithm.
+  |ctrlp_open_func|.............Use custom file opening functions.
+  |ctrlp_status_func|...........Change CtrlP's two statuslines.
+  |ctrlp_buffer_func|...........Call custom functions in the CtrlP buffer.
+  |ctrlp_match_func|............Replace the built-in matching algorithm.
 
 -------------------------------------------------------------------------------
 Detailed descriptions and default values:~
 <
 
                                                       *'g:ctrlp_switch_buffer'*
-When opening a file, if it's already opened in a window somewhere CtrlP will
-try to jump to it instead of opening a new instance: >
+When opening a file, if it's already open in a window somewhere, CtrlP will try
+to jump to it instead of opening a new instance: >
   let g:ctrlp_switch_buffer = 'Et'
 <
   e - jump when <cr> is pressed, but only to windows in the current tab.
   t - jump when <c-t> is pressed, but only to windows in another tab.
-  v - like e, but jump when <c-v> is pressed.
-  h - like e, but jump when <c-x> is pressed.
-  E, T, V, H - like e, t, v and h respectively, but jump to windows anywhere.
-  0 or <empty-string> - disable this feature.
+  v - like "e", but jump when <c-v> is pressed.
+  h - like "e", but jump when <c-x> is pressed.
+  E, T, V, H - like "e", "t", "v", and "h", but jump to windows anywhere.
+  0 or <empty> - disable this feature.
 
                                                        *'g:ctrlp_reuse_window'*
 When opening a file with <cr>, CtrlP avoids opening it in windows created by
                                                   *'g:ctrlp_working_path_mode'*
 When starting up, CtrlP sets its local working directory according to this
 variable: >
-  let g:ctrlp_working_path_mode = 'rc'
+  let g:ctrlp_working_path_mode = 'ra'
 <
   c - the directory of the current file.
+  a - like "c", but only applies when the current working directory outside of
+      CtrlP isn't a direct ancestor of the directory of the current file.
   r - the nearest ancestor that contains one of these directories or files:
       .git .hg .svn .bzr _darcs
-  0 or <empty-string> - don't manage working directory.
+  w - begin finding a root from the current working directory outside of CtrlP
+      instead of from the directory of the current file (default). Only applies
+      when "r" is also present.
+  0 or <empty> - disable this feature.
 
-Note #1: you can use b:ctrlp_working_path_mode (a |b:var|) to set this option
-on a per buffer basis.
+Note #1: if "a" or "c" is included with "r", use the behavior of "a" or "c" (as
+a fallback) when a root can't be found.
 
-Note #2: with both 'r' and 'c' in the option, when a root isn't found, use the
-directory of the current file.
+Note #2: you can use a |b:var| to set this option on a per buffer basis.
 
                                                        *'g:ctrlp_root_markers'*
 Use this to set your own root markers in addition to the default ones (.git,
 .hg, .svn, .bzr, and _darcs). Your markers will take precedence: >
   let g:ctrlp_root_markers = ['']
 <
+Note: you can use a |b:var| to set this option on a per buffer basis.
 
                                                         *'g:ctrlp_use_caching'*
 Enable/Disable per-session caching: >
   1 - Enable caching.
   n - When bigger than 1, disable caching and use the number as the limit to
       enable caching again.
+
 Note: you can quickly purge the cache by pressing <F5> while inside CtrlP.
 
                                                 *'g:ctrlp_clear_cache_on_exit'*
   let g:ctrlp_cache_dir = $HOME.'/.cache/ctrlp'
 <
 
-                                                           *'g:ctrlp_dotfiles'*
-Set this to 0 if you don't want CtrlP to scan for dotfiles and dotdirs: >
-  let g:ctrlp_dotfiles = 1
+                                                        *'g:ctrlp_show_hidden'*
+Set this to 1 if you want CtrlP to scan for dotfiles and dotdirs: >
+  let g:ctrlp_show_hidden = 0
 <
+Note: does not apply when a command defined with |g:ctrlp_user_command| is
+being used.
 
                                                            *'ctrlp-wildignore'*
 You can use Vim's |'wildignore'| to exclude files and directories from the
   let g:ctrlp_custom_ignore = ''
 <
 Examples: >
-  let g:ctrlp_custom_ignore = '\v[\/](\.git|\.hg|\.svn)$'
+  let g:ctrlp_custom_ignore = '\v[\/]\.(git|hg|svn)$'
   let g:ctrlp_custom_ignore = {
-    \ 'dir':  '\v[\/](\.git|\.hg|\.svn)$',
-    \ 'file': '\.exe$\|\.so$\|\.dll$',
+    \ 'dir':  '\v[\/]\.(git|hg|svn)$',
+    \ 'file': '\v\.(exe|so|dll)$',
     \ 'link': 'SOME_BAD_SYMBOLIC_LINKS',
     \ }
   let g:ctrlp_custom_ignore = {
 The maximum number of files to scan, set to 0 for no limit: >
   let g:ctrlp_max_files = 10000
 <
+Note: does not apply when a command defined with |g:ctrlp_user_command| is
+being used.
 
                                                           *'g:ctrlp_max_depth'*
 The maximum depth of a directory tree to recurse into: >
   let g:ctrlp_max_depth = 40
 <
-Note: the larger these values, the more memory Vim uses.
+Note: does not apply when a command defined with |g:ctrlp_user_command| is
+being used.
 
                                                        *'g:ctrlp_user_command'*
 Specify an external tool to use for listing files instead of using Vim's
   let g:ctrlp_user_command = ['.hg', 'for /f "tokens=1" %%a in (''hg root'') '
     \ . 'do hg --cwd %s status -numac -I . %%a']           " Windows
 <
-Note #1: if the fallback_command is empty or not defined, |globpath()| will
-then be used when searching outside a repo.
+Note #1: if the fallback_command is empty or the 'fallback' key is not defined,
+|globpath()| will then be used when scanning outside of a repository.
 
 Note #2: unless the |Dictionary| format is used and 'ignore' is defined and set
 to 1, the |wildignore| and |g:ctrlp_custom_ignore| options do not apply when
-these custom commands are being used. When not defined, 'ignore' is set to 0 by
+these custom commands are being used. When not present, 'ignore' is set to 0 by
 default to retain the performance advantage of using external commands.
 
 Note #3: when changing the option's variable type, remember to |:unlet| it
 first or restart Vim to avoid the "E706: Variable type mismatch" error.
 
+Note #4: you can use a |b:var| to set this option on a per buffer basis.
+
                                                         *'g:ctrlp_max_history'*
 The maximum number of input strings you want CtrlP to remember. The default
 value mirrors Vim's global |'history'| option: >
 
                                                       *'g:ctrlp_open_new_file'*
 Use this option to specify how the newly created file is to be opened when
-pressing <c-y>:
-  t - in a new tab
-  h - in a new horizontal split
-  v - in a new vertical split
-  r - in the current window
->
+pressing <c-y>: >
   let g:ctrlp_open_new_file = 'v'
 <
+  t - in a new tab.
+  h - in a new horizontal split.
+  v - in a new vertical split.
+  r - in the current window.
 
                                                 *'g:ctrlp_open_multiple_files'*
 If non-zero, this will enable opening multiple files with <c-z> and <c-o>: >
   i - all files as hidden buffers.
   j - after opening, jump to the first opened tab or window.
   r - open the first file in the current window, then the remaining files in
-      new splits or new tabs depending on which of h, v and t is also present.
+      new splits or new tabs depending on which of "h", "v" and "t" is also
+      present.
 
                                                             *'g:ctrlp_arg_map'*
 When this is set to 1, the <c-o> and <c-y> mappings will accept one extra key
   1 - follow but ignore looped internal symlinks to avoid duplicates.
   2 - follow all symlinks indiscriminately.
 
+Note: does not apply when a command defined with |g:ctrlp_user_command| is
+being used.
+
                                                         *'g:ctrlp_lazy_update'*
 Set this to 1 to enable the lazy-update feature: only update the match window
 after typing's been stopped for a certain amount of time: >
   let g:ctrlp_default_input = 'anystring'
 <
 
+                                                             *'g:ctrlp_abbrev'*
+Define input abbreviations that can be expanded (either internally or visibly)
+in the prompt: >
+  let g:ctrlp_abbrev = {}
+<
+Examples: >
+  let g:ctrlp_abbrev = {
+    \ 'gmode': 'i',
+    \ 'abbrevs': [
+      \ {
+        \ 'pattern': '^cd b',
+        \ 'expanded': '@cd ~/.vim/bundle',
+        \ 'mode': 'pfrz',
+      \ },
+      \ {
+        \ 'pattern': '\(^@.\+\|\\\@<!:.\+\)\@<! ',
+        \ 'expanded': '.\{-}',
+        \ 'mode': 'pfr',
+      \ },
+      \ {
+        \ 'pattern': '\\\@<!:.\+\zs\\\@<! ',
+        \ 'expanded': '\ ',
+        \ 'mode': 'pfz',
+      \ },
+      \ ]
+    \ }
+<
+The 'pattern' string is regexp matched against the entered input. The expansion
+is as if the 'expanded' string was typed into the prompt.
+
+For 'gmode' (optional):
+  i - expand internally (default).
+  t - insert the expanded results into the prompt as you type.
+  k - insert the expanded results when a non-keyword character is typed. Only
+      applies when "t" is also present.
+
+For 'mode' (of each entry; optional):
+  f - only in filename mode.
+  p - only in full path mode.
+  r - only in regexp mode.
+  z - only in fuzzy mode.
+  n - only when creating a new file with <c-y> (use the expanded string in the
+      new filename).
+  c - only when auto-completing directory names with <tab> (expand the pattern
+      immediately before doing the auto-completion).
+  <empty> or not defined - always enable.
+
+Note: the abbrev entries are evaluated in sequence, so a later entry can be
+evaluated against the expanded result of a previous entry; this includes itself
+when 'gmode' is "t".
+
+                                                           *'g:ctrlp_key_loop'*
+An experimental feature. Set this to 1 to enable input looping for the typing
+of multi-byte characters: >
+  let g:ctrlp_key_loop = 0
+<
+Note #1: when set, this option resets the |g:ctrlp_lazy_update| option.
+
+Note #2: you can toggle this feature inside the prompt with a custom mapping: >
+  let g:ctrlp_prompt_mappings = { 'ToggleKeyLoop()': ['<F3>'] }
+<
+
                                                          *'g:ctrlp_use_migemo'*
 Set this to 1 to use Migemo Pattern for Japanese filenames. Migemo Search only
 works in regexp mode. To split the pattern, separate words with space: >
    Open CtrlP in find Most-Recently-Used file mode.
 
                                                                *:CtrlPLastMode*
-:CtrlPLastMode
-   Open CtrlP in the last mode used.
+:CtrlPLastMode [--dir]
+   Open CtrlP in the last mode used. When having the "--dir" argument, also
+   reuse the last working directory.
 
                                                                    *:CtrlPRoot*
 :CtrlPRoot
-    This acts like |:CtrlP| with |g:ctrlp_working_path_mode| = 'rc' and ignores
+    This acts like |:CtrlP| with |g:ctrlp_working_path_mode| = 'r' and ignores
     the variable's current value.
 
                                                              *:CtrlPClearCache*
                                                                     *:CtrlPTag*
   * Tag mode:~
     - Name: 'tag'
-    - Command: ':CtrlPTag'
+    - Command: ":CtrlPTag"
     - Search for a tag within a generated central tags file, and jump to the
       definition. Use the Vim's option |'tags'| to specify the names and the
       locations of the tags file(s).
                                                               *:CtrlPBufTagAll*
   * Buffer Tag mode:~
     - Name: 'buffertag'
-    - Commands: ':CtrlPBufTag [buffer]',
-                ':CtrlPBufTagAll'.
+    - Commands: ":CtrlPBufTag [buffer]",
+                ":CtrlPBufTagAll".
     - Search for a tag within the current buffer or all listed buffers and jump
       to the definition. Requires |exuberant_ctags| or compatible programs.
 
                                                                *:CtrlPQuickfix*
   * Quickfix mode:~
     - Name: 'quickfix'
-    - Command: ':CtrlPQuickfix'
+    - Command: ":CtrlPQuickfix"
     - Search for an entry in the current quickfix errors and jump to it.
 
                                                                     *:CtrlPDir*
   * Directory mode:~
     - Name: 'dir'
-    - Command: ':CtrlPDir [starting-directory]'
+    - Command: ":CtrlPDir [starting-directory]"
     - Search for a directory and change the working directory to it.
     - Mappings:
       + <cr> change the local working directory for CtrlP and keep it open.
                                                                     *:CtrlPRTS*
   * Runtime script mode:~
     - Name: 'rtscript'
-    - Command: ':CtrlPRTS'
+    - Command: ":CtrlPRTS"
     - Search for files (vimscripts, docs, snippets...) in runtimepath.
 
                                                                    *:CtrlPUndo*
   * Undo mode:~
     - Name: 'undo'
-    - Command: ':CtrlPUndo'
+    - Command: ":CtrlPUndo"
     - Browse undo history.
 
                                                                    *:CtrlPLine*
   * Line mode:~
     - Name: 'line'
-    - Command: ':CtrlPLine'
+    - Command: ":CtrlPLine"
     - Search for a line in all listed buffers.
 
                                                                  *:CtrlPChange*
                                                               *:CtrlPChangeAll*
   * Change list mode:~
     - Name: 'changes'
-    - Commands: ':CtrlPChange [buffer]',
-                ':CtrlPChangeAll'.
+    - Commands: ":CtrlPChange [buffer]",
+                ":CtrlPChangeAll".
     - Search for and jump to a recent change in the current buffer or in all
       listed buffers.
 
                                                                   *:CtrlPMixed*
   * Mixed mode:~
     - Name: 'mixed'
-    - Command: ':CtrlPMixed'
+    - Command: ":CtrlPMixed"
     - Search in files, buffers and MRU files at the same time.
 
                                                             *:CtrlPBookmarkDir*
                                                          *:CtrlPBookmarkDirAdd*
   * BookmarkDir mode:~
     - Name: 'bookmarkdir'
-    - Commands: ':CtrlPBookmarkDir',
-                ':CtrlPBookmarkDirAdd [directory]'.
+    - Commands: ":CtrlPBookmarkDir",
+                ":CtrlPBookmarkDirAdd [directory]".
     - Search for a bookmarked directory and change the working directory to it.
     - Mappings:
       + <cr> change the local working directory for CtrlP, keep it open and
 ===============================================================================
 CHANGELOG                                                     *ctrlp-changelog*
 
+    + New options: |g:ctrlp_abbrev|,
+                   |g:ctrlp_key_loop|,
+                   |g:ctrlp_open_func|,
+                   |g:ctrlp_tabpage_position|
+    + Rename:
+        *g:ctrlp_dotfiles* -> |g:ctrlp_show_hidden|.
     + Change |g:ctrlp_switch_buffer|'s and |g:ctrlp_working_path_mode|'s type
       (old values still work).
     + New key for |g:ctrlp_user_command| when it's a Dictionary: 'ignore'.
-    + New options: |g:ctrlp_open_func|.
-                   |g:ctrlp_tabpage_position|.
 
 Before 2012/06/15~
 

File plugin/ctrlp.vim

 com! -n=? -com=dir CtrlPMRUFiles cal ctrlp#init(2, { 'dir': <q-args> })
 
 com! -bar CtrlPBuffer   cal ctrlp#init(1)
-com! -bar CtrlPLastMode cal ctrlp#init(-1)
+com! -n=? CtrlPLastMode cal ctrlp#init(-1, { 'args': <q-args> })
 
 com! -bar CtrlPClearCache     cal ctrlp#clr()
 com! -bar CtrlPClearAllCaches cal ctrlp#clra()
-com! -bar CtrlPReload         cal ctrlp#reset()
 
 com! -bar ClearCtrlPCache     cal ctrlp#clr()
 com! -bar ClearAllCtrlPCaches cal ctrlp#clra()
-com! -bar ResetCtrlP          cal ctrlp#reset()
 
 com! -bar CtrlPCurWD   cal ctrlp#init(0, { 'mode': '' })
 com! -bar CtrlPCurFile cal ctrlp#init(0, { 'mode': 'c' })
-com! -bar CtrlPRoot    cal ctrlp#init(0, { 'mode': 'rc' })
+com! -bar CtrlPRoot    cal ctrlp#init(0, { 'mode': 'r' })
 
 if g:ctrlp_map != '' && !hasmapto(':<c-u>'.g:ctrlp_cmd.'<cr>', 'n')
 	exe 'nn <silent>' g:ctrlp_map ':<c-u>'.g:ctrlp_cmd.'<cr>'
 
 com! -n=? -com=dir CtrlPBookmarkDirAdd
 	\ cal ctrlp#call('ctrlp#bookmarkdir#add', <q-args>)
+
+" vim:ts=2:sw=2:sts=2