diff --git a/autoload/ctrlp.vim b/autoload/ctrlp.vim index 39bc0a99..575ebcd5 100644 --- a/autoload/ctrlp.vim +++ b/autoload/ctrlp.vim @@ -1164,6 +1164,12 @@ fu! ctrlp#setdir(path, ...) let cmd = a:0 ? a:1 : 'lc!' sil! exe cmd ctrlp#fnesc(a:path) endf + +fu! ctrlp#setlcdir() + if exists('*haslocaldir') + cal ctrlp#setdir(getcwd(), haslocaldir() ? 'lc!' : 'cd!') + en +endf " Highlighting {{{2 fu! s:syntax() for [ke, va] in items(s:hlgrps) | if !hlexists('CtrlP'.ke) @@ -1430,8 +1436,8 @@ fu! s:openfile(cmd, fid, tail, ...) if !empty(a:tail) || j2l sil! norm! zvzz en - if exists('*haslocaldir') && cmd != 'bad' - cal ctrlp#setdir(getcwd(), haslocaldir() ? 'lc!' : 'cd!') + if cmd != 'bad' + cal ctrlp#setlcdir() en endf diff --git a/autoload/ctrlp/quickfix.vim b/autoload/ctrlp/quickfix.vim index 3238762a..2537ee75 100644 --- a/autoload/ctrlp/quickfix.vim +++ b/autoload/ctrlp/quickfix.vim @@ -48,6 +48,7 @@ fu! ctrlp#quickfix#accept(mode, str) exe cmd ctrlp#fnesc(filpath) cal cursor(items[2], items[3]) sil! norm! zvzz + cal ctrlp#setlcdir() endf fu! ctrlp#quickfix#id() diff --git a/autoload/ctrlp/tag.vim b/autoload/ctrlp/tag.vim index e96099b1..9807defb 100644 --- a/autoload/ctrlp/tag.vim +++ b/autoload/ctrlp/tag.vim @@ -93,6 +93,7 @@ fu! ctrlp#tag#accept(mode, str) el exe cmd tg en + cal ctrlp#setlcdir() endf fu! ctrlp#tag#id() diff --git a/doc/ctrlp.txt b/doc/ctrlp.txt index 7517f61d..bf11d87b 100644 --- a/doc/ctrlp.txt +++ b/doc/ctrlp.txt @@ -87,6 +87,17 @@ When opening a file with or , if the file’s already opened somewhere 2 - jump tab as well if the buffer’s opened in another tab. 0 - disable this feature. + *'g:ctrlp_reuse_window'* +When opening a file with , |CtrlP| avoids opening it in windows created by +plugins, help and quickfix. Use this to setup some exceptions: > + let g:ctrlp_reuse_window = 'netrw' +< +Acceptable values are partial names or filetypes of the special buffers. Use +|regexp| to specify the pattern. +Example: > + let g:ctrlp_reuse_window = 'netrw\|help\|quickfix' +< + *'g:ctrlp_working_path_mode'* When starting up, |CtrlP| sets its local working directory according to this variable: > @@ -224,9 +235,9 @@ Examples: > Note #1: the `*/` in front of each directory glob is required. Note #2: |wildignore| influences the result of |expand()|, |globpath()| and -|glob()| which many plugins use to find stuff on the system (e.g. fugitive.vim -looks for .git/, some other plugins look for external .exe tools on Windows). -So be a little mindful of what you put in your |wildignore|. +|glob()| which many plugins use to find stuff on the system (e.g. VCS related +plugins look for .git/, .hg/,... some other plugins look for external *.exe +tools on Windows). So be a little mindful of what you put in your |wildignore|. *'g:ctrlp_custom_ignore'* In addition to |'wildignore'|, use this for files and directories you want only @@ -345,17 +356,6 @@ Pressing or will then prompt for a keypress. The key can be: Any other key - use the behavior specified with |g:ctrlp_open_new_file| and |g:ctrlp_open_multiple_files|. - *'g:ctrlp_reuse_window'* -When opening a file with , |CtrlP| avoids opening it in windows created by -plugins, help and quickfix. Use this to setup some exceptions: > - let g:ctrlp_reuse_window = 'netrw' -< -Acceptable values are partial names or filetypes of the special buffers. Use -|regexp| to specify the pattern. -Example: > - let g:ctrlp_reuse_window = 'netrw\|help\|quickfix' -< - *'g:ctrlp_follow_symlinks'* Set this to 1 to follow symbolic links when listing files: > let g:ctrlp_follow_symlinks = 0 diff --git a/readme.md b/readme.md index 83a70e26..3ae63603 100644 --- a/readme.md +++ b/readme.md @@ -47,18 +47,14 @@ according to this variable: 0 - don’t manage working directory. 1 - the parent directory of the current file. 2 - the nearest ancestor that contains one of these directories or files: + `.git/` `.hg/` `.svn/` `.bzr/` `_darcs/` - .git/ - .hg/ - .bzr/ - _darcs/ - -* 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, use the Vim’s +option `wildignore` and/or the option `g:ctrlp_custom_ignore`. Examples: ```vim - set wildignore+=*/.git/*,*/.hg/*,*/.svn/* " for Linux/MacOSX - set wildignore+=.git\*,.hg\*,.svn\* " for Windows + set wildignore+=*/tmp/*,*.so,*.swp,*.zip " MacOSX/Linux + set wildignore+=tmp\*,*.swp,*.zip,*.exe " Windows let g:ctrlp_custom_ignore = '\.git$\|\.hg$\|\.svn$' let g:ctrlp_custom_ignore = { @@ -71,8 +67,8 @@ Vim’s option `wildignore` and/or the option `g:ctrlp_custom_ignore`. Examples: * Use a custom file listing command with: ```vim - let g:ctrlp_user_command = 'find %s -type f' " MacOSX/Linux - let g:ctrlp_user_command = 'dir %s /-n /b /s /a-d' " Windows + let g:ctrlp_user_command = 'find %s -type f' " MacOSX/Linux + let g:ctrlp_user_command = 'dir %s /-n /b /s /a-d' " Windows ``` _Check [the docs][2] for more mappings, commands and options._