kien avatar kien committed ec5f272 Draft

Enable <c-o> when s:marked doesn't exist [...]

Update docs.
Enable default input for non-path.

Comments (0)

Files changed (2)

autoload/ctrlp.vim

 " File:          autoload/ctrlp.vim
 " Description:   Fuzzy file, buffer, mru, tag, etc finder.
 " Author:        Kien Nguyen <github.com/kien>
-" Version:       1.7.7
+" Version:       1.77
 " =============================================================================
 
 " ** Static variables {{{1
 endf
 " - SetDefTxt() {{{1
 fu! s:SetDefTxt()
-	if s:deftxt == '0' || !s:ispath | retu | en
+	if s:deftxt == '0' || ( s:deftxt == 1 && !s:ispath ) | retu | en
 	let txt = s:deftxt
 	if !type(txt)
 		let txt = txt && !stridx(s:crfpath, s:dyncwd)
 endf
 
 fu! s:OpenMulti(...)
-	if !exists('s:marked') || s:opmul == '0' || !s:ispath | retu -1 | en
+	let has_marked = exists('s:marked')
+	if ( !has_marked && a:0 ) || s:opmul == '0' || !s:ispath
+		\ || ( s:itemtype > 2 && s:getextvar('opmul') != 1 )
+		retu -1
+	en
 	" Get the options
 	let [nr, md] = [matchstr(s:opmul, '\d\+'), matchstr(s:opmul, '[thvi]')]
-	let [ur, jf] = [matchstr(s:opmul, 'r') == 'r', matchstr(s:opmul, 'j') == 'j']
+	let [ur, jf] = [s:opmul =~ 'r', s:opmul =~ 'j']
 	let md = a:0 ? a:1 : ( md == '' ? 'v' : md )
 	let nopt = exists('g:ctrlp_open_multiple_files')
-	if s:argmap && !a:0
-		let md = s:argmaps(md, 0)
+	if !has_marked
+		let line = !empty(s:lines) ? s:lines[line('.') - 1] : ''
+		if line == '' | retu | en
+		let marked = { 1 : fnamemodify(line, ':p') }
+		let [nr, ur, jf, nopt] = ['1', 0, 0, 1]
+	en
+	if ( s:argmap || !has_marked ) && !a:0
+		let md = s:argmaps(md, !has_marked ? 2 : 0)
 		if md == 'c'
 			cal s:unmarksigns()
 			unl! s:marked
 		en
 		if md =~ '\v^c(ancel)?$' | retu | en
 		let nr = nr == '0' ? ( nopt ? '' : '1' ) : nr
+		let ur = !has_marked && md == 'r' ? 1 : ur
 	en
-	let mkd = values(s:marked)
+	let mkd = values(has_marked ? s:marked : marked)
 	cal s:sanstail(join(s:prompt, ''))
 	cal s:PrtExit()
 	if nr == '0' || md == 'i'
 	let roh = [
 		\ ['OpenMulti', '/h[i]dden/[c]lear', ['i', 'c']],
 		\ ['CreateNewFile', '/[r]eplace', ['r']],
+		\ ['OpenSeleted', '/[r]eplace/h[i]dden', ['r', 'i']],
 		\ ]
 	let str = roh[a:i][0].': [t]ab/[v]ertical/[h]orizontal'.roh[a:i][1].'? '
 	retu s:choices(str, ['t', 'v', 'h'] + roh[a:i][2], 's:argmaps', [a:md, a:i])
-*ctrlp.txt*       Fuzzy file, buffer, mru, tag, ... finder. v1.7.7
+*ctrlp.txt*       Fuzzy file, buffer, mru, tag, ... finder. v1.77
 *CtrlP* *ControlP* *'ctrlp'* *'ctrl-p'*
 ===============================================================================
 #                                                                             #
   v - each file in a new vertical split.
   i - all files as hidden buffers.
   j - after opening, jump to the first opened tab or window.
-  Reuse the current window:
-  tr,
-  hr,
-  vr - open the first file in the current window, then the remaining files in
-       new splits or new tabs just like with t, h, v.
+  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.
 
                                                             *'g:ctrlp_arg_map'*
 When this is set to 1, the <c-o> and <c-y> mappings will accept one extra key
 path: >
   let g:ctrlp_default_input = 0
 <
+Instead of 1 or 0, if the value of the option is a string, it'll be used as-is
+as the default input: >
+  let g:ctrlp_default_input = 'anystring'
+<
 
                                                          *'g:ctrlp_use_migemo'*
 Set this to 1 to use Migemo Pattern for Japanese filenames. Migemo Search only
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.