diff --git a/autoload/ctrlp.vim b/autoload/ctrlp.vim index db05ec0..a74dcfc 100644 --- a/autoload/ctrlp.vim +++ b/autoload/ctrlp.vim @@ -61,7 +61,7 @@ let [s:pref, s:opts, s:new_opts] = ['g:ctrlp_', { \ 'extensions': ['s:extensions', []], \ 'follow_symlinks': ['s:folsym', 0], \ 'highlight_match': ['s:mathi', [1, 'CtrlPMatch']], - \ 'jump_to_buffer': ['s:jmptobuf', 2], + \ 'jump_to_buffer': ['s:jmptobuf', 'Et'], \ 'lazy_update': ['s:lazy', 0], \ 'match_func': ['s:matcher', {}], \ 'match_window_bottom': ['s:mwbottom', 1], @@ -847,16 +847,19 @@ fu! ctrlp#acceptfile(mode, line, ...) cal s:PrtExit() let [bufnr, tail] = [bufnr('^'.filpath.'$'), s:tail()] let j2l = a:0 ? a:1 : str2nr(matchstr(tail, '^ +\D*\zs\d\+\ze\D*')) - if s:jmptobuf && bufnr > 0 && md =~ 'e\|t' + if ( s:jmptobuf =~ md || ( s:jmptobuf && md =~ '[et]' ) ) && bufnr > 0 \ && !( md == 'e' && bufnr == bufnr('%') ) let [jmpb, bufwinnr] = [1, bufwinnr(bufnr)] - let buftab = s:jmptobuf > 1 ? s:buftab(bufnr, md) : [0, 0] + let buftab = ( s:jmptobuf =~# '[tTVH]' || s:jmptobuf > 1 ) + \ ? s:buftab(bufnr, md) : [0, 0] en " Switch to existing buffer or open new one - if exists('jmpb') && bufwinnr > 0 && md != 't' + if exists('jmpb') && bufwinnr > 0 + \ && !( md == 't' && ( s:jmptobuf !~# toupper(md) || buftab[0] ) ) exe bufwinnr.'winc w' if j2l | cal ctrlp#j2l(j2l) | en elsei exists('jmpb') && buftab[0] + \ && !( md =~ '[evh]' && s:jmptobuf !~# toupper(md) ) exe 'tabn' buftab[0] exe buftab[1].'winc w' if j2l | cal ctrlp#j2l(j2l) | en diff --git a/doc/ctrlp.txt b/doc/ctrlp.txt index 87f5ae8..d8263aa 100644 --- a/doc/ctrlp.txt +++ b/doc/ctrlp.txt @@ -128,13 +128,16 @@ Set the maximum height of the match window: > < *'g:ctrlp_switch_buffer'* -When opening a file with or , if the file's already opened somewhere -CtrlP will try to jump to it instead of opening a new instance: > - let g:ctrlp_switch_buffer = 2 +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: > + let g:ctrlp_switch_buffer = 'Et' < - 1 - only jump to the buffer if it's opened in the current tab. - 2 - jump tab as well if the buffer's opened in another tab. - 0 - disable this feature. + e - jump when is pressed, but only to windows in the current tab. + t - jump when is pressed, but only to windows in another tab. + v - like e, but jump when is pressed. + h - like e, but jump when is pressed. + E, T, V, H - like e, t, v and h respectively, but jump to windows anywhere. + 0 or - disable this feature. *'g:ctrlp_reuse_window'* When opening a file with , CtrlP avoids opening it in windows created by @@ -165,7 +168,7 @@ variable: > c - 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. + 0 or - don't manage working directory. Note #1: you can use b:ctrlp_working_path_mode (a |b:var|) to set this option on a per buffer basis. @@ -1160,6 +1163,8 @@ Special thanks:~ =============================================================================== CHANGELOG *ctrlp-changelog* + + 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|.