diff --git a/autoload/ctrlp.vim b/autoload/ctrlp.vim index 5214e38..fb79d29 100644 --- a/autoload/ctrlp.vim +++ b/autoload/ctrlp.vim @@ -60,10 +60,10 @@ fu! s:opts() \ 'PrtClear()': [''], \ 'PrtSelectMove("j")': ['', ''], \ 'PrtSelectMove("k")': ['', ''], - \ 'PrtSelectMove("t")': [''], - \ 'PrtSelectMove("b")': [''], - \ 'PrtSelectMove("u")': [''], - \ 'PrtSelectMove("d")': [''], + \ 'PrtSelectMove("t")': ['', ''], + \ 'PrtSelectMove("b")': ['', ''], + \ 'PrtSelectMove("u")': ['', ''], + \ 'PrtSelectMove("d")': ['', ''], \ 'PrtHistory(-1)': [''], \ 'PrtHistory(1)': [''], \ 'AcceptSelection("e")': ['', '<2-LeftMouse>'], @@ -97,22 +97,6 @@ fu! s:opts() if type(s:urprtmaps) == 4 cal extend(s:prtmaps, s:urprtmaps) en - let s:prtunmaps = [ - \ 'PrtBS()', - \ 'PrtDelete()', - \ 'PrtDeleteWord()', - \ 'PrtClear()', - \ 'PrtCurStart()', - \ 'PrtCurEnd()', - \ 'PrtCurLeft()', - \ 'PrtCurRight()', - \ 'PrtHistory(-1)', - \ 'PrtHistory(1)', - \ 'PrtInsert("w")', - \ 'PrtInsert("s")', - \ 'PrtInsert("v")', - \ 'PrtInsert("+")', - \ ] " Global options let s:glbs = { 'magic': 1, 'to': 1, 'tm': 0, 'sb': 1, 'hls': 0, 'im': 0, \ 'report': 9999, 'sc': 0, 'ss': 0, 'siso': 0, 'mfd': 200, 'mouse': 'n', @@ -136,6 +120,31 @@ let s:fpats = { \ '^\S\\?$': '\\?', \ } +" Mappings +let s:prtunmaps = [ + \ 'PrtBS()', + \ 'PrtDelete()', + \ 'PrtDeleteWord()', + \ 'PrtClear()', + \ 'PrtCurStart()', + \ 'PrtCurEnd()', + \ 'PrtCurLeft()', + \ 'PrtCurRight()', + \ 'PrtHistory(-1)', + \ 'PrtHistory(1)', + \ 'PrtInsert("w")', + \ 'PrtInsert("s")', + \ 'PrtInsert("v")', + \ 'PrtInsert("+")', + \ ] +let s:kprange = { + \ 'Plus': '+', + \ 'Minus': '-', + \ 'Divide': '/', + \ 'Multiply': '*', + \ 'Point': '.', + \ } + " Highlight groups let s:hlgrps = { \ 'NoEntries': 'Error', @@ -361,18 +370,17 @@ endf fu! s:Render(lines, pat, ipt) let lines = a:lines " Setup the match window - let s:height = min([len(lines), s:winh]) + let [&ma, s:height] = [1, min([len(lines), s:winh])] sil! exe '%d _ | res' s:height " Print the new items if empty(lines) - setl nocul let s:matched = [] cal setline(1, ' == NO ENTRIES ==') + setl noma nocul cal s:unmarksigns() if s:dohighlight() | cal clearmatches() | en retu en - setl cul " Sort if not MRU if ( s:itemtype != 2 && !exists('g:ctrlp_nolimit') ) \ || !empty(join(s:prompt, '')) @@ -384,6 +392,7 @@ fu! s:Render(lines, pat, ipt) let s:matched = copy(lines) cal map(lines, 's:formatline(v:val, a:ipt)') cal setline(1, lines) + setl noma cul exe 'keepj norm!' ( s:mwreverse ? 'G' : 'gg' ).'1|' cal s:unmarksigns() cal s:remarksigns() @@ -623,6 +632,13 @@ fu! s:MapKeys(...) for each in range(32, 126) exe printf(cmd, each, pfunc, escape(nr2char(each), '"|\'), dojmp) endfo + let kpcmd = substitute(cmd, 'char-%d', 'k%s', '') + for each in range(0, 9) + exe printf(kpcmd, each, pfunc, each, dojmp) + endfo + for [ke, va] in items(s:kprange) + exe printf(kpcmd, ke, pfunc, va, dojmp) + endfo " Special keys if a:0 < 2 cal call('s:MapSpecs', a:0 && !a:1 ? [1] : []) @@ -712,8 +728,8 @@ fu! s:SetWD(...) "{{{1 unl! s:foundroot endf " * AcceptSelection() {{{1 -fu! ctrlp#acceptfile(mode, matchstr, ...) - let [md, filpath] = [a:mode, fnamemodify(a:matchstr, ':p')] +fu! ctrlp#acceptfile(mode, line, ...) + 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*')) @@ -976,7 +992,7 @@ fu! ctrlp#statusline() let focus = s:Focus() ? 'prt' : 'win' let byfname = s:byfname ? 'file' : 'path' let marked = s:opmul != '0' ? - \ exists('s:marked') ? ' <'.s:dismrk().'>' : ' <>' : '' + \ exists('s:marked') ? ' <'.s:dismrk().'>' : ' <->' : '' if has_key(s:status, 'main') let args = [focus, byfname, s:regexp, prv, item, nxt, marked] let &l:stl = call(s:status['main'], args) @@ -1004,8 +1020,8 @@ fu! ctrlp#progress(enum) endf " Paths {{{2 fu! s:formatline(str, ipt) - retu '> '.( a:ipt && ( s:winw - ( s:dosigns() ? 2 : 0 ) - 2 ) - \ < s:strwidth(a:str) ? pathshorten(a:str) : a:str ) + let cond = a:ipt && ( s:winw - 4 ) < s:strwidth(a:str) + retu '> '.( cond ? pathshorten(a:str) : a:str ) endf fu! s:dircompl(be, sd) diff --git a/doc/ctrlp.txt b/doc/ctrlp.txt index ba2730e..9243031 100644 --- a/doc/ctrlp.txt +++ b/doc/ctrlp.txt @@ -165,10 +165,9 @@ only need to keep the lines that you’ve changed the values (inside []): > < Note: In some terminals, it’s not possible to remap without also changing (|key-codes|). So if pressing moves the cursor to the left instead of -deleting a char for you, add this to your |vimrc| to change the default +deleting a char for you, add this to your |vimrc| to disable the default mapping: > let g:ctrlp_prompt_mappings = { - \ 'PrtBS()': ['', '', ''], \ 'PrtCurLeft()': ['', ''], \ } < @@ -213,7 +212,7 @@ Set to 1 to sort the MRU file list to most-recently-entered-buffer order: > < *'g:ctrlp_dotfiles'* -Set this to 0 if you don’t want |CtrlP| to search for dotfiles and dotdirs: > +Set this to 0 if you don’t want |CtrlP| to scan for dotfiles and dotdirs: > let g:ctrlp_dotfiles = 1 < You can use |'wildignore'| to exclude anything from the search. @@ -762,6 +761,8 @@ Special thanks:~ =============================================================================== CHANGELOG *ctrlp-changelog* +Before 2012/03/01~ + + New option: |g:ctrlp_mruf_last_entered| change MRU to recently-entered. + Extend |g:ctrlp_user_command| to support multiple commands. @@ -854,7 +855,7 @@ Before 2011/09/12~ |g:ctrlp_mruf_max|, |g:ctrlp_mruf_exclude|, |g:ctrlp_mruf_include| - + New command: |:CtrlPMRUFiles| + + New command: |:CtrlPMRU| First public release: 2011/09/06~ diff --git a/plugin/ctrlp.vim b/plugin/ctrlp.vim index 5150c43..5cc8c90 100644 --- a/plugin/ctrlp.vim +++ b/plugin/ctrlp.vim @@ -26,7 +26,7 @@ com! CtrlPCurWD cal ctrlp#init(0, 0) com! CtrlPCurFile cal ctrlp#init(0, 1) com! CtrlPRoot cal ctrlp#init(0, 2) -if g:ctrlp_map != '' +if g:ctrlp_map != '' && !hasmapto(':'.g:ctrlp_cmd.'', 'n') exe 'nn ' g:ctrlp_map ':'.g:ctrlp_cmd.'' en diff --git a/readme.md b/readme.md index 8d106fe..83a70e2 100644 --- a/readme.md +++ b/readme.md @@ -16,14 +16,17 @@ Full path fuzzy __file__, __buffer__, __mru__ and __tag__ finder for Vim. Once CtrlP is open: -* Press `` and `` to switch between find file, buffer, and MRU file modes. +* Press `` and `` to switch between find file, buffer, and MRU file +modes. * Press `` to switch to filename only search instead of full path. * Press `` to purge the cache for the current directory and get new files. * Use `*` or `|` in the prompt to submit the string as a Vim’s regexp pattern. * Or press `` to switch to regexp mode. -* End the input string with a colon `:` followed by a command to execute after opening the file. +* End the input string with a colon `:` followed by a command to execute after +opening the file. e.g. `abc:45` will open the file matched the pattern and jump to line 45. -* Submit two dots `..` as the input string to go backward the directory tree by 1 level. +* Submit two dots `..` as the input string to go backward the directory tree by +1 level. * Use `` to create a new file and its parent dirs. * Use `` to mark/unmark files and `` to open them. @@ -34,7 +37,8 @@ e.g. `abc:45` will open the file matched the pattern and jump to line 45. let g:ctrlp_map = '' ``` -* When CtrlP is invoked, it automatically sets the working directory according to this variable: +* When CtrlP is invoked, it automatically sets its local working directory +according to this variable: ```vim let g:ctrlp_working_path_mode = 2 @@ -48,10 +52,9 @@ e.g. `abc:45` will open the file matched the pattern and jump to line 45. .hg/ .bzr/ _darcs/ - root.dir -* If you want to exclude directories or files from the search, you can use the Vim’s option `wildignore` -and/or the option `g:ctrlp_custom_ignore`. Examples: +* If you want to exclude directories or files from the search, you can use the +Vim’s option `wildignore` and/or the option `g:ctrlp_custom_ignore`. Examples: ```vim set wildignore+=*/.git/*,*/.hg/*,*/.svn/* " for Linux/MacOSX