From 64e4fd64eb7f836f3500c11235a4d671570ebb15 Mon Sep 17 00:00:00 2001 From: darrenli Date: Mon, 16 Sep 2013 16:54:02 -0700 Subject: [PATCH 01/67] Include custom file listing warning in readme's exclusion notes. --- readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme.md b/readme.md index bcd07c7f..7568f813 100644 --- a/readme.md +++ b/readme.md @@ -57,7 +57,7 @@ Use `:diffthis` when opening multiple files to run `:diffthis` on the first 4 fi Define additional root markers with the `g:ctrlp_root_markers` option. -* Exclude files and directories using Vim's `wildignore` and CtrlP's own `g:ctrlp_custom_ignore`: +* Exclude files and directories using Vim's `wildignore` and CtrlP's own `g:ctrlp_custom_ignore`. If a custom listing command is being used, exclusions are ignored: ```vim set wildignore+=*/tmp/*,*.so,*.swp,*.zip " MacOSX/Linux From b5f826172498f5535561d44618fa31f608cc0852 Mon Sep 17 00:00:00 2001 From: Aaron Jensen Date: Thu, 10 Oct 2013 23:03:32 -0700 Subject: [PATCH 02/67] Highlight only individual characters --- autoload/ctrlp.vim | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/autoload/ctrlp.vim b/autoload/ctrlp.vim index 19ac1463..d88448d5 100644 --- a/autoload/ctrlp.vim +++ b/autoload/ctrlp.vim @@ -1622,12 +1622,30 @@ fu! s:highlight(pat, grp) if s:matcher != {} | retu | en cal clearmatches() if !empty(a:pat) && s:ispath - let pat = s:regexp ? substitute(a:pat, '\\\@ \\zs', 'g') : a:pat - if s:byfname - let pat = substitute(pat, '\[\^\(.\{-}\)\]\\{-}', '[^\\/\1]\\{-}', 'g') - let pat = substitute(pat, '\$\@ \\zs', 'g') + cal matchadd(a:grp, ( s:martcs == '' ? '\c' : '\C' ).pat) + el + let pat = a:pat + + " calculate how many letters are here + let lettercount = len(split(pat, '\\{-}')) + for i in range(lettercount) + " surround the letter we care about with \zs and \ze so only it is + " highlighted in this go. + let letterpat = substitute(pat, '^\%(.\{-}\\{-}\)\{'.i.'}\zs.\{-}\ze\%(\[^.*\)\?$', '\\zs\0\\ze', '') + + if s:byfname + " replace [^x] with [^/x] to make sure no slashes between letters + let letterpat = substitute(letterpat, '\[\^\(.\{-}\)\]\\{-}', '[^\\/\1]\\{-}', 'g') + " replace the end to make sure no slashes follow the pattern + let letterpat = substitute(letterpat, '\$\@') en endf From 3559e2ba200cb96d1c00f6f5b0375f7569646efe Mon Sep 17 00:00:00 2001 From: Aaron Jensen Date: Thu, 10 Oct 2013 23:50:23 -0700 Subject: [PATCH 03/67] More complicated, but even better highlighting Prefers grouping words together, examples: app/assets/javascripts/common --- ------ > app/common app/models/group_user.rb --- ------ ---- > appmodelsuser --- autoload/ctrlp.vim | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/autoload/ctrlp.vim b/autoload/ctrlp.vim index d88448d5..454ff2e0 100644 --- a/autoload/ctrlp.vim +++ b/autoload/ctrlp.vim @@ -1632,8 +1632,11 @@ fu! s:highlight(pat, grp) let lettercount = len(split(pat, '\\{-}')) for i in range(lettercount) " surround the letter we care about with \zs and \ze so only it is - " highlighted in this go. - let letterpat = substitute(pat, '^\%(.\{-}\\{-}\)\{'.i.'}\zs.\{-}\ze\%(\[^.*\)\?$', '\\zs\0\\ze', '') + " highlighted in this go. Prefer the letter right next to the previous + " one, otherwise scan out to the last one + let letterpat = substitute(pat, + \ '^\%(\\\?.\zs\[\^\\\?.\]\\{-}\)\{'.i.'}\(\\\?.\)\%(\[\^\\\?.\]\\{-}\)\?\ze.*$', + \ '\\(\\zs\1\\|.*\\zs\1\\)\\ze.\\{-}', '') if s:byfname " replace [^x] with [^/x] to make sure no slashes between letters From 96cf005bd5905996ccfe206eb668491518bdc6ef Mon Sep 17 00:00:00 2001 From: mattn Date: Wed, 27 Nov 2013 11:00:41 +0900 Subject: [PATCH 04/67] Hide cursor shape --- autoload/ctrlp.vim | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/autoload/ctrlp.vim b/autoload/ctrlp.vim index 19ac1463..4c26f631 100644 --- a/autoload/ctrlp.vim +++ b/autoload/ctrlp.vim @@ -888,17 +888,23 @@ fu! s:MapSpecs() 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), ':\zs.\+\ze$') - exe ( cmd != '' ? cmd : 'norm '.chr ) - en - endw + let t_ve = &t_ve + set t_ve= + try + 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), ':\zs.\+\ze$') + exe ( cmd != '' ? cmd : 'norm '.chr ) + en + endw + fina + let &t_ve = t_ve + endt endf " * Toggling {{{1 fu! s:ToggleFocus() From 04ddbf4cb2c921fb2c1210ce4213c1ea41c142d0 Mon Sep 17 00:00:00 2001 From: codepiano Date: Mon, 9 Dec 2013 00:38:45 +0800 Subject: [PATCH 05/67] translate the ctrlp doc into Chinese --- doc/ctrlp_cn.txt | 1406 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 1406 insertions(+) create mode 100644 doc/ctrlp_cn.txt diff --git a/doc/ctrlp_cn.txt b/doc/ctrlp_cn.txt new file mode 100644 index 00000000..45ac6480 --- /dev/null +++ b/doc/ctrlp_cn.txt @@ -0,0 +1,1406 @@ +*ctrlp.txt* 模糊的 文件, 缓冲区, 最近最多使用, 标签, ... 检索. v1.79 +*CtrlP* *ControlP* *'ctrlp'* *'ctrl-p'* +=============================================================================== +# # +# :::::::: ::::::::::: ::::::::: ::: ::::::::: # +# :+: :+: :+: :+: :+: :+: :+: :+: # +# +:+ +:+ +:+ +:+ +:+ +:+ +:+ # +# +#+ +#+ +#++:++#: +#+ +#++:++#+ # +# +#+ +#+ +#+ +#+ +#+ +#+ # +# #+# #+# #+# #+# #+# #+# #+# # +# ######## ### ### ### ########## ### # +# # +=============================================================================== +名词对照(译注) + + buffer:缓冲区 mapping:按键绑定 + mru:最近最多使用 prompt:提示符面板 + tag:标签 tab:页签 + tab:制表符 + +=============================================================================== +内容 *ctrlp-content* + + 1. 介绍.............................................|ctrlp-intro| + 2. 选项.............................................|ctrlp-options| + 3. 命令.............................................|ctrlp-commands| + 4. 按键绑定.........................................|ctrlp-mappings| + 5. 输入格式.........................................|ctrlp-input-formats| + 6. 扩展.............................................|ctrlp-extensions| + +=============================================================================== +介绍 *ctrlp-intro* + +带有直观接口的全路径模糊文件, 缓冲区, 最近最多使用, 标签, ... 检索。 +使用纯净的Vimscript编写,可以运行在MacVim,gVim和版本号7.0以上的Vim中。 +全面支持Vim的正则表达式 |regexp| 作为搜索模式,内建最近最多使用文件监测, +项目根目录定位和更多特性。 + +开启可选的扩展(标记,目录,rtscripts...),参考 |ctrlp-extensions| 。 + +=============================================================================== +OPTIONS *ctrlp-options* + +总览:~ + + |loaded_ctrlp|................禁用插件。 + |ctrlp_map|...................默认按键绑定。 + |ctrlp_cmd|...................默认按键绑定调用的命令。 + |ctrlp_by_filename|...........是否默认开启文件名模式。 + |ctrlp_regexp|................是否默认开启正则表达式模式。 + |ctrlp_match_window|..........匹配窗口的显示位置。 + |ctrlp_switch_buffer|.........如果文件已在缓冲区中打开,跳转到该打开的缓冲区。 + |ctrlp_reuse_window|..........重用特殊窗口(帮助、快速修复 |quickfix| ,等等)。 + |ctrlp_tabpage_position|......新标签页出现的位置。 + |ctrlp_working_path_mode|.....如何设置CtrlP的本地工作目录。 + |ctrlp_root_markers|..........额外的,高优先级的根目录标识。 + |ctrlp_use_caching|...........针对每个会话,设置是否开启缓存的。 + |ctrlp_clear_cache_on_exit|...退出Vim后是否保留缓存。 + |ctrlp_cache_dir|.............缓存目录的位置。 + |ctrlp_show_hidden|...........是否显示隐藏文件和隐藏文件夹。 + |ctrlp_custom_ignore|.........使用 |globpath()| 时自定义忽略的文件或目录。 + |ctrlp_max_files|.............扫描文件的最大数目。 + |ctrlp_max_depth|.............扫描目录的最大层数。 + |ctrlp_user_command|..........使用外部的扫描工具。 + |ctrlp_max_history|...........历史提示符面板中保留的最大条目数。 + |ctrlp_open_new_file|.........由创建的文件的打开方式。 + |ctrlp_open_multiple_files|...由选择的文件的打开方式。 + |ctrlp_arg_map|...............是否拦截 命令。 + |ctrlp_follow_symlinks|.......是否跟随链接。 + |ctrlp_lazy_update|...........停止输入时才更新。 + |ctrlp_default_input|.........为提示符面板提供一个种子。 + |ctrlp_abbrev|................输入缩写。 + |ctrlp_key_loop|..............为多字节输入开启输入事件循环。 + |ctrlp_use_migemo|............为日语文件名启用Migemo模式。 + |ctrlp_prompt_mappings|.......改变提示符面板内部的按键绑定。 + + 最近最常使用模式: + |ctrlp_mruf_max|..............记录的最近最常最多使用的最大数据。 + |ctrlp_mruf_exclude|..........需要被排除的文件。 + |ctrlp_mruf_include|..........需要被记录的文件。 + |ctrlp_mruf_relative|.........只显示在工作目录内的最近最多使用。 + |ctrlp_mruf_default_order|....禁用排序。 + |ctrlp_mruf_case_sensitive|...最近最多使用文件是否大小写敏感。 + |ctrlp_mruf_save_on_update|...只要有一个新的条目添加,就保存到磁盘。 + + 缓冲区标签模式: (开启此模式,参考 |ctrlp-extensions| ) + |g:ctrlp_buftag_ctags_bin|....兼容的ctags二进制程序的位置。 + |g:ctrlp_buftag_systemenc|....ctags命令的编码。 + |g:ctrlp_buftag_types|........添加新的文件类型和设置命令行参数。 + + 高级选项: + |ctrlp_open_func|.............使用自定义的打开文件的函数。 + |ctrlp_status_func|...........改变CtrlP的两个状态栏 + |ctrlp_buffer_func|...........在CtrlP的缓冲区内调用自定义的函数。 + |ctrlp_match_func|............替换内建的匹配算法。 + +------------------------------------------------------------------------------- +详细描述和默认值:~ + + *'g:ctrlp_map'* +使用该选项来改变普通模式 |Normal| 下调用CtrlP的按键绑定: > + let g:ctrlp_map = '' +< + + *'g:ctrlp_cmd'* + +设置当按下上面的按键绑定时,使用的默认打开命令: > + let g:ctrlp_cmd = 'CtrlP' +< + + *'g:loaded_ctrlp'* +使用该选项完全禁用插件: > + let g:loaded_ctrlp = 1 +< + + *'g:ctrlp_by_filename'* +修改该选项为1,设置默认为按文件名搜索(否则为全路径): > + let g:ctrlp_by_filename = 0 +< +在提示符面板内可以使用 来切换。 + + *'g:ctrlp_regexp'* +修改该选项为1,设置默认为使用正则表达式匹配。: > + let g:ctrlp_regexp = 0 +< +在提示符面板内可以使用 来切换。 + + *'g:ctrlp_match_window'* +改变匹配窗口的位置,结果的排列顺序,最小和最大高度: > + let g:ctrlp_match_window = '' +< +例子: > + let g:ctrlp_match_window = 'bottom,order:btt,min:1,max:10,results:10' +< +位置: (默认:底部) + top - 在屏幕顶部显示匹配窗口。 + bottom - 在屏幕底部显示匹配窗口。 + +结果的排列顺序: (默认: btt) + order:ttb - 从顶部到底部。 + order:btt - 从底部到顶部。 + +最小和最大高度: + min:{n} - 最少显示 {n} 行 (默认: 1). + max:{n} - 最多显示 {n} 行 (默认: 10). + +结果集的最大数目: + results:{n} - 列出最多 {n} 条结果 (默认: 和最大高度同步). + +注意: 当一个设置项没有被设置时,将会使用默认值。 + + *'g:ctrlp_switch_buffer'* +当尝试打开一个文件时,如果它已经在某个窗口被打开,CtrlP会尝试跳到那个窗口,而 +不是新打开一个实例。: > + let g:ctrlp_switch_buffer = 'Et' +< + e - 当 被按下时跳转,但是只跳转到当前页签内的窗口内。 + t - 当 被按下时跳转, 但是只跳转到其它标签的窗口内。 + v - 类似 "e", 但是当 被按下时跳转。 + h - 类似 "e", 但是当 被按下时跳转。 + E, T, V, H - 行为类似 "e", "t", "v", and "h", 但是跳转到任何地方的窗口中。 + 0 或者 - 禁用这项功能。 + + *'g:ctrlp_reuse_window'* +当使用 打开新文件时,CtrlP避免在插件,帮助,快速修复创建的窗口中打开该文 +件。使用该选项来设置一些例外: > + let g:ctrlp_reuse_window = 'netrw' +< +接受的值可以为特殊缓冲区的名字的一部分,文件类型或者缓冲区类型使用正则表达式来 +指定匹配模式。 +例子: > + let g:ctrlp_reuse_window = 'netrw\|help\|quickfix' +< + + *'g:ctrlp_tabpage_position'* +新打开页签的位置: > + let g:ctrlp_tabpage_position = 'ac' +< + a - 后面。 + b - 前面。 + c - 当前页签。 + l - 最后一个页签。 + f - 第一个页签。 + + *'g:ctrlp_working_path_mode'* +当启动时,CtrlP依据这个变量来设置它的工作目录: > + let g:ctrlp_working_path_mode = 'ra' +< + c - 当前文件所在的目录。 + a - 类似 "c", 但是只有在CtrlP之外的当前工作目录不是当前文件所在目录的直接祖 + 先时才生效。(译注:请参考https://github.com/kien/ctrlp.vim/issues/397) + r - 包含下列文件或者目录的最近的祖先: + .git .hg .svn .bzr _darcs + w - 开始从CtrlP的工作目录之外的目录,而不是当前文件所在的目录(默认)查找根 + 目录。只有在"r"选项存在的时候才生效。 + 0 或者 - 禁用这项功能。 + +注意 #1: 如果 "a" 或者 "c" 和 "r"一起被包含,当无法找到根目录时使用 "a" 或者 +"c" 的行为(作为备选)。 + +注意 #2: 你可以在每个缓冲区内使用 |b:var| 来设置该选项。 + + *'g:ctrlp_root_markers'* +使用该选项来设置自定义的根目录标记作为对默认标记(.hg, .svn, .bzr, and _darcs) +的补充。自定义的标记具有优先权: > + let g:ctrlp_root_markers = [''] +< +注意: 你可以在每个缓冲区内使用 |b:var| 来设置该选项。 + + *'g:ctrlp_use_caching'* +启用/禁用每个会话的缓存: > + let g:ctrlp_use_caching = 1 +< + 0 - 禁用缓存。 + 1 - 启用缓存。 + n - 当大于1时,禁用缓存,使用该数值作为重新启用缓存的限制条件。 + +注意: 当在CtrlP中时你可以使用 来快速的清除缓存。 + + *'g:ctrlp_clear_cache_on_exit'* +设置该选项为0通过退出Vim时不删除缓存文件来启用跨回话的缓存: > + let g:ctrlp_clear_cache_on_exit = 1 +< + + *'g:ctrlp_cache_dir'* +设置存储缓存文件的目录: > + let g:ctrlp_cache_dir = $HOME.'/.cache/ctrlp' +< + + *'g:ctrlp_show_hidden'* +如果你想CtrlP扫描隐藏文件和目录,设置该选项为1: > + let g:ctrlp_show_hidden = 0 +< +注意: 当命令使用 |g:ctrlp_user_command| 定义时该选项无效。 + + *'ctrlp-wildignore'* +你可以使用Vim的 |'wildignore'| 来从结果集中排序文件或目录。 +例子: > + " 排除版本控制文件 + set wildignore+=*/.git/*,*/.hg/*,*/.svn/* " Linux/MacOSX + set wildignore+=*\\.git\\*,*\\.hg\\*,*\\.svn\\* " Windows ('noshellslash') +< +注意 #1: 每个目录设置前的字符 `*/` 是必须的。 + +注意 #2: |wildignore| 影响 |expand()| , |globpath()| 和 |glob()| 的结果,这些函数被很 +多插件用来在系统中执行查找。(例如和版本控制系统有关的插件在查找.git/、.hg/等, +一些其他插件用来在Windows上查找外部的*.exe工具),所以要修改 |wildignore| 时请先 +考虑清楚。 + + *'g:ctrlp_custom_ignore'* +作为对 |'wildignore'| 的补充,用来设置你只是想在CtrlP中隐藏的文件和目录。使用正 +则表达式来指定匹配模式: > + let g:ctrlp_custom_ignore = '' +< +例子: > + let g:ctrlp_custom_ignore = '\v[\/]\.(git|hg|svn)$' + let g:ctrlp_custom_ignore = { + \ 'dir': '\v[\/]\.(git|hg|svn)$', + \ 'file': '\v\.(exe|so|dll)$', + \ 'link': 'SOME_BAD_SYMBOLIC_LINKS', + \ } + let g:ctrlp_custom_ignore = { + \ 'file': '\v(\.cpp|\.h|\.hh|\.cxx)@ + let g:ctrlp_max_files = 10000 +< +注意: 当命令使用 |g:ctrlp_user_command| 定义时该选项无效。 + + *'g:ctrlp_max_depth'* +目录树递归的最大层数: > + let g:ctrlp_max_depth = 40 +< +注意: 当命令使用 |g:ctrlp_user_command| 定义时该选项无效。 + + *'g:ctrlp_user_command'* +指定用来代替Vim的 |globpath()| 的外部工具来列出文件,使用 %s 代表目标目录: > + let g:ctrlp_user_command = '' +< +例子: > + let g:ctrlp_user_command = 'find %s -type f' " MacOSX/Linux + let g:ctrlp_user_command = 'dir %s /-n /b /s /a-d' " Windows +< +你也可以使用 'grep', 'findstr' 或者其它东西来过滤结果集。 +例子: > + let g:ctrlp_user_command = + \ 'find %s -type f | grep -v -P "\.jpg$|/tmp/"' " MacOSX/Linux + let g:ctrlp_user_command = + \ 'dir %s /-n /b /s /a-d | findstr /v /l ".jpg \\tmp\\"' " Windows +< +在扫描一个大型项目时,在仓库目录中使用版本控制系统的列出命令会加快扫描速度: > + let g:ctrlp_user_command = [root_marker, listing_command, fallback_command] + let g:ctrlp_user_command = { + \ 'types': { + \ 1: [root_marker_1, listing_command_1], + \ n: [root_marker_n, listing_command_n], + \ }, + \ 'fallback': fallback_command, + \ 'ignore': 0 or 1 + \ } +< +一些例子: > + " 单个版本控制系统,列出命令不会列出没有被追踪的文件: + let g:ctrlp_user_command = ['.git', 'cd %s && git ls-files'] + let g:ctrlp_user_command = ['.hg', 'hg --cwd %s locate -I .'] + + " 多个版本控制系统: + let g:ctrlp_user_command = { + \ 'types': { + \ 1: ['.git', 'cd %s && git ls-files'], + \ 2: ['.hg', 'hg --cwd %s locate -I .'], + \ }, + \ 'fallback': 'find %s -type f' + \ } + + " 单个版本控制系统,列出命令列出没有被追踪的文件(较慢): + let g:ctrlp_user_command = + \ ['.git', 'cd %s && git ls-files . -co --exclude-standard'] + + let g:ctrlp_user_command = + \ ['.hg', 'hg --cwd %s status -numac -I . $(hg root)'] " MacOSX/Linux + + let g:ctrlp_user_command = ['.hg', 'for /f "tokens=1" %%a in (''hg root'') ' + \ . 'do hg --cwd %s status -numac -I . %%a'] " Windows +< +注意 #1: 在 |Dictionary| 格式, 'fallback' 和 'ignore' 是可选的,在 |List| 格式, +备选命令是可选的。 + +注意 #2: 如果备选命令是空的或者属性 'fallback' 没有定义,当扫描仓库之外目录时, +|globpath()| 会被使用。 + +注意 #3: 除非使用了 |Dictionary| 格式并且 'ignore' 被定义并且设置为1,当这些自 +定义的命令被使用时 |wildignore| 和 |g:ctrlp_custom_ignore| 选项不会生效。没有出现 +时,'ignore' 被默认设置为0来保留使用外部命令的性能优势。 + +注意 #4: 当改变了选项的变量类型时,记得先 |:unlet| ,或者重启Vim来避免这个错误: +"E706: Variable type mismatch" 。 + +注意 #5: 你可以在每个缓冲区内使用 |b:var| 来设置该选项。 + + *'g:ctrlp_max_history'* +你希望CtrlP记录的用户输入历史的最大数目。默认值是Vim的全局选项 |'history'| : > + let g:ctrlp_max_history = &history +< +设置为0来禁用提示符面板的历史。使用 来浏览历史。 + + *'g:ctrlp_open_new_file'* +使用该选项指定当使用 打开新建的文件时,文件的打开方式: > + let g:ctrlp_open_new_file = 'v' +< + t - 在新页签中。 + h - 在新的水平分割窗口。 + v - 在新的竖直分割窗口。 + r - 在当前窗口。 + + *'g:ctrlp_open_multiple_files'* +如果非0, 会启用使用 打开多个文件: > + let g:ctrlp_open_multiple_files = 'v' +< +例子: > + let g:ctrlp_open_multiple_files = '2vjr' +< +对于数字: + - 如果指定,会被用来作为打开文件时创建的窗口或者页签的最大数量(剩余的会在隐 + 藏的缓冲区中打开)。 + - 如果没有指定, 会打开所有文件,每个在一个新的窗口或者页签中。 + +对于字母: + t - 每个文件在一个新页签中。 + h - 每个文件在一个新的水平分割窗口中。 + v - 每个文件在一个新的竖直分割窗口中。 + i - 所有的文件在隐藏的缓冲区中。 + j - 打开以后,跳转到第一个打开的页签或者窗口。 + r - 在当前窗口打开第一个文件,其他文件根据同时出现的"h","v"和"t"中的一个, + 在新的分割窗口或者页签中打开。 + + *'g:ctrlp_arg_map'* +当设置为1时, 会接收一个额外的键值作为参数,来覆盖默认行为: > + let g:ctrlp_arg_map = 0 +< +按下 或者 会提示一次按键。按键可以是: + t - 在新标签页中打开。 + h - 每个文件在一个新的水平分割窗口中。 + v - 每个文件在一个新的竖直分割窗口中。 + i - 所有的文件在隐藏的缓冲区中(只有 生效)。 + c - 清楚标记的文件(只有 生效)。 + r - 在当前窗口中打开(只有 生效)。 + , , - 取消并且回到提示符面板。 + - 使用 |g:ctrlp_open_new_file| 和 |g:ctrlp_open_multiple_files| 指定的默 + 认行为。 + + + *'g:ctrlp_follow_symlinks'* +如果非0,当列出文件时CtrlP会跟随链接: > + let g:ctrlp_follow_symlinks = 0 +< + 0 - 不要跟随链接。 + 1 - 跟随但是忽略内部循环的链接,避免重复。 + 2 - 无差别的跟随所有链接。 + +注意: 当命令使用 |g:ctrlp_user_command| 定义时该选项无效。 + + *'g:ctrlp_lazy_update'* +设置为1将开启延迟更新特性:只在输入停止一个确定的时间后才更新匹配窗口: > + let g:ctrlp_lazy_update = 0 +< +如果设置为1,在250毫秒后更新。如果大于1,数字会被作为延迟时间使用。 + + *'g:ctrlp_default_input'* +设置为1将为提示符面板提供当前文件的相对路径作为种子: > + let g:ctrlp_default_input = 0 +< +如果不指定1或0,如果选项的值是字符串,会被用来作为默认输入: > + let g:ctrlp_default_input = 'anystring' +< + + *'g:ctrlp_abbrev'* +定义可以在提示面包内被扩展(内部的或者可见的)的输入缩写: > + let g:ctrlp_abbrev = {} +< +例子: > + let g:ctrlp_abbrev = { + \ 'gmode': 'i', + \ 'abbrevs': [ + \ { + \ 'pattern': '^cd b', + \ 'expanded': '@cd ~/.vim/bundle', + \ 'mode': 'pfrz', + \ }, + \ { + \ 'pattern': '\(^@.\+\|\\\@ 创建新文件时(使用扩展后的字符串作为文件名)。 + c - 当使用 自动补全目录名时(在自动补全之前立即扩展模式)。 + 或者未定义 - 总是启用。 + +注意: 缩写条目按顺序求值,后求值的条目会覆盖先求值的条目;当 'gmode' 为"t"时, +包括他自己。 + + *'g:ctrlp_key_loop'* +一个实验性的特性。设置该选项为1将为多字节字符开启输入事件循环: > + let g:ctrlp_key_loop = 0 +< +注意 #1: 当设置时,该选项会重置 |g:ctrlp_lazy_update| 选项。 + +注意 #2: 你可以在提示符面板使用自定义的按键绑定切换这个特性: > + let g:ctrlp_prompt_mappings = { 'ToggleKeyLoop()': [''] } +< + + *'g:ctrlp_use_migemo'* +设置该选项为1将为日文文件名使用Migemo模式。Migemo搜索只在正则模式下有效。 使 +用空格分割单词来分离模式: > + let g:ctrlp_use_migemo = 0 +< + + *'g:ctrlp_prompt_mappings'* +使用该选项来自定义CtrlP的提示窗口内的按键绑定为你喜欢的方式。你只需要保留你改 +变值(在[]内部)的行: > + let g:ctrlp_prompt_mappings = { + \ 'PrtBS()': ['', ''], + \ 'PrtDelete()': [''], + \ 'PrtDeleteWord()': [''], + \ 'PrtClear()': [''], + \ 'PrtSelectMove("j")': ['', ''], + \ 'PrtSelectMove("k")': ['', ''], + \ 'PrtSelectMove("t")': ['', ''], + \ 'PrtSelectMove("b")': ['', ''], + \ 'PrtSelectMove("u")': ['', ''], + \ 'PrtSelectMove("d")': ['', ''], + \ 'PrtHistory(-1)': [''], + \ 'PrtHistory(1)': [''], + \ 'AcceptSelection("e")': ['', '<2-LeftMouse>'], + \ 'AcceptSelection("h")': ['', '', ''], + \ 'AcceptSelection("t")': [''], + \ 'AcceptSelection("v")': ['', ''], + \ 'ToggleFocus()': [''], + \ 'ToggleRegex()': [''], + \ 'ToggleByFname()': [''], + \ 'ToggleType(1)': ['', ''], + \ 'ToggleType(-1)': ['', ''], + \ 'PrtExpandDir()': [''], + \ 'PrtInsert("c")': ['', ''], + \ 'PrtInsert()': [''], + \ 'PrtCurStart()': [''], + \ 'PrtCurEnd()': [''], + \ 'PrtCurLeft()': ['', '', ''], + \ 'PrtCurRight()': ['', ''], + \ 'PrtClearCache()': [''], + \ 'PrtDeleteEnt()': [''], + \ 'CreateNewFile()': [''], + \ 'MarkToOpen()': [''], + \ 'OpenMulti()': [''], + \ 'PrtExit()': ['', '', ''], + \ } +< +注意: 如果按 后光标向左移动一个字符而不是删除一个字符,在你的.vimrc中添加 +下面的设置来禁用插件默认的 绑定: > + let g:ctrlp_prompt_mappings = { 'PrtCurLeft()': ['', ''] } +< + +---------------------------------------- +MRU mode options:~ + + *'g:ctrlp_mruf_max'* +指定你希望CtrlP记录的最近打开的文件历史的数目: > + let g:ctrlp_mruf_max = 250 +< + + *'g:ctrlp_mruf_exclude'* +你不希望CtrlP记录的文件。使用正则表达式来指定模式: > + let g:ctrlp_mruf_exclude = '' +< +例子: > + let g:ctrlp_mruf_exclude = '/tmp/.*\|/temp/.*' " MacOSX/Linux + let g:ctrlp_mruf_exclude = '^C:\\dev\\tmp\\.*' " Windows +< + + *'g:ctrlp_mruf_include'* +如果你想让CtrlP只记录某些文件,在这里指定: > + let g:ctrlp_mruf_include = '' +< +例子: > + let g:ctrlp_mruf_include = '\.py$\|\.rb$' +< + + *'g:ctrlp_mruf_relative'* +设置该选项为1将只显示在当前工作目录内的最近最多使用文件: > + let g:ctrlp_mruf_relative = 0 +< +注意: 你可以在提示符面板使用自定义的按键绑定切换这个特性: > + let g:ctrlp_prompt_mappings = { 'ToggleMRURelative()': [''] } +< + + *'g:ctrlp_mruf_default_order'* +设置该选项为1将在最近最多使用模式搜索时禁用排序: > + let g:ctrlp_mruf_default_order = 0 +< + + *'g:ctrlp_mruf_case_sensitive'* +将该选项和你的文件系统大小写敏感性保持一致来避免重复的最近最多使用条目: > + let g:ctrlp_mruf_case_sensitive = 1 +< + + *'g:ctrlp_mruf_save_on_update'* +设置该选项为0将不会每当有一个新条目增加就把最近最多使用列表保存到磁盘文件,而 +是在退出Vim时才保存: > + let g:ctrlp_mruf_save_on_update = 1 +< + +---------------------------------------- +高级选项:~ + + *'g:ctrlp_open_func'* +使用一个自定义函数来打开选定的文件: > + let g:ctrlp_open_func = {} +< +例子: > + let g:ctrlp_open_func = { + \ 'files' : 'Function_Name_1', + \ 'buffers' : 'Function_Name_2', + \ 'mru files' : 'Function_Name_3', + \ } +< +函数结构: > + function! Function_Name(action, line) + " 参数: + " | + " +- a:action : 打开的动作: + " | + 'e' : 用户按下 (默认) + " | + 'h' : 用户按下 (默认) + " | + 'v' : 用户按下 (默认) + " | + 't' : 用户按下 (默认) + " | + 'x' : 用户使用 终端对话框 (默认) 选择"e[x]ternal"。 + " | + " +- a:line : 选择的文件。 + + endfunction +< +注意: 当使用打开多个文件时无效。 + +例子: 当 被按下时在默认浏览器中打开HTML文件,否则在Vim中打开 > + function! HTMLOpenFunc(action, line) + if a:action =~ '^[tx]$' && fnamemodify(a:line, ':e') =~? '^html\?$' + + " 获取文件名 + let filename = fnameescape(fnamemodify(a:line, ':p')) + + " 关闭CtrlP + call ctrlp#exit() + + " 打开文件 + silent! execute '!xdg-open' filename + + elseif a:action == 'x' && fnamemodify(a:line, ':e') !~? '^html\?$' + + " 不是HTML文件,再次模拟 按键并且等待新的输入 + call feedkeys("\") + + else + + " 使用CtrlP的默认的打开文件的函数 + call call('ctrlp#acceptfile', [a:action, a:line]) + + endif + endfunction + + let g:ctrlp_open_func = { 'files': 'HTMLOpenFunc' } +< + + *'g:ctrlp_status_func'* +为CtrlP窗口使用自定义的状态栏: > + let g:ctrlp_status_func = {} +< +例子: > + let g:ctrlp_status_func = { + \ 'main': 'Function_Name_1', + \ 'prog': 'Function_Name_2', + \ } +< +函数结构: > + " 主状态栏 + function! Function_Name_1(focus, byfname, regex, prev, item, next, marked) + " 参数: + " | + " +- a:focus : 提示符面板的焦点: "prt" 或者 "win"。 + " | + " +- a:byfname : 在文件名模式还是全路径模式: "file" 或者 "path"。 + " | + " +- a:regex : 是否在正则表达式模式: 1 or 0。 + " | + " +- a:prev : 前一个搜索模式。 + " | + " +- a:item : 当前的搜索模式。 + " | + " +- a:next : 下一个搜索模式。 + " | + " +- a:marked : 被标记文件的数目,或者一个逗号分隔的被标记的文件名列表。 + + return full_statusline + endfunction + + " 状态栏进度条 + function! Function_Name_2(str) + " a:str : 一个当前已扫描的文件数,或者一个当前扫描目录和用户命令的字符串。 + + return full_statusline + endfunction +< +一个可用的例子,参见 https://gist.github.com/1610859 。 + + *'g:ctrlp_buffer_func'* +指定一个会在启动或者退出CtrlP缓冲区时被调用的函数: > + let g:ctrlp_buffer_func = {} +< +例子: > + let g:ctrlp_buffer_func = { + \ 'enter': 'Function_Name_1', + \ 'exit': 'Function_Name_2', + \ } +< + + *'g:ctrlp_match_func'* +为CtrlP设置一个额外的模糊匹配函数: > + let g:ctrlp_match_func = {} +< +例子: > + let g:ctrlp_match_func = { 'match': 'Function_Name' } +< +函数结构: > + function! Function_Name(items, str, limit, mmode, ispath, crfile, regex) + " 参数: + " | + " +- a:items : 搜索条目的全列表。 + " | + " +- a:str : 用户输入的字符串。 + " | + " +- a:limit : 匹配窗口的最大高度。可以用来限制返回的条目数量。 + " | + " +- a:mmode : 在匹配模式。可以是下列字符串之一: + " | + "full-line": 匹配整行。 + " | + "filename-only": 只匹配文件名。 + " | + "first-non-tab": 匹配到第一个制表符。 + " | + "until-last-tab": 匹配到最后一个制表符。 + " | + " +- a:ispath : 搜索文件,缓冲区,最近最多使用,混合,目录和rtscript模. + " | 式时为1。其它为0。 + " | + " +- a:crfile : 当前窗口中的文件。当a:ispath为1时应该被搜索结果排除在外 + " | + " +- a:regex : 是否在正则表达式模式: 1 or 0. + + return list_of_matched_items + endfunction +< + +注意: 你可以通过 { 'arg_type': 'dict' } 扩展上面的任何选项,这样就可以通过 +一个字典类型的参数来传递所有的函数参数。使用参数名作为字典的键值。 + +例子: > + let g:ctrlp_status_func = { + \ 'arg_type' : 'dict', + \ 'enter': 'Function_Name_1', + \ 'exit': 'Function_Name_2', + \ } + + function! Function_Name_1(dict) + " where dict == { + " \ 'focus': value, + " \ 'byfname': value, + " \ 'regex': value, + " \ ... + " } + endfunction +< + +=============================================================================== +命令 *ctrlp-commands* + + *:CtrlP* +:CtrlP [起始目录] + 用文件搜索模式打开CtrlP。 + + 如果没有给定参数,|g:ctrlp_working_path_mode| 会被用来决定起始目录。 + + 在输入时你可以使用 自动补全[起始目录]。 + + *:CtrlPBuffer* +:CtrlPBuffer + 用缓冲区搜索模式打开CtrlP。 + + *:CtrlPMRU* +:CtrlPMRU + 用最近最多使用模式打开CtrlP。 + + *:CtrlPLastMode* +:CtrlPLastMode [--dir] + 用上一次使用的模式打开CtrlP。当提供了"--dir"参数,也重用上一次的工作目录。 + + *:CtrlPRoot* +:CtrlPRoot + 行为类似使用了 |g:ctrlp_working_path_mode| = 'r' 并且忽略了该变量的当前值的 + |:CtrlP| 命令。 + + *:CtrlPClearCache* +:CtrlPClearCache + 清除当前工作目录的缓存。和在CtrlP内按 效果一样。 + 使用 |g:ctrlp_use_caching| 来启用或禁用缓存。 + + *:CtrlPClearAllCaches* +:CtrlPClearAllCaches + 删除在 |g:ctrlp_cache_dir| 中定义的缓存目录中的所有缓存文件。 + +------------------------------------------------------------------------------- +由扩展提供的命令参见 |ctrlp-extensions| 。 + +=============================================================================== +按键绑定 *ctrlp-mappings* + + *'ctrlp-'* + + 普通模式 |Normal| 下默认以文件搜索模式打开CtrlP提示符面板。 + +---------------------------------------- +已经在提示符面板中:~ + + + 在全路径搜索和文件名搜索间切换。 + 注意: 在文件名搜索模式,提示符面板的提示符是'>d>',而不是'>>>' + + *'ctrlp-fullregexp'* + 在字符串搜索模式和正则表达式模式之间切换。 + 注意: 在全正则表达式模式,提示符面板的提示符是'r>>',而不是'>>>' + + 详细参见: |input-formats| (指引)和 |g:ctrlp_regexp_search| 选项。 + + , 'forward' 前进 + + 切换到序列里面的 'next' 后一个搜索模式。 + + , 'backward' 后退 + + 切换到序列里面的 'previous' 前一个搜索模式。 + + *'ctrlp-autocompletion'* + 自动补全在提示符面板的当前工作路径中的目录名。 + + + 在匹配窗口和提示符面板之间切换焦点。 + + , + + 退出CtrlP。 + +移动:~ + + , + + 向下移动。 + + , + + 向上移动。 + + + 移动光标到提示符面板的 'start' 开头。 + + + 移动光标到提示符面板的 'end' 末尾。 + + , + , + + 向左 'left' 移动一个字符。 + + , + + 向右 'right' 移动一个字符。 + +编辑:~ + + , + + 删除前一个字符。 + + + 删除当前字符。 + + + 删除前一个单词。 + + + 清除输入。 + +浏览输入历史:~ + + + 提示符面板历史里的下一个字符串。 + + + 提示符面板历史里的上一个字符串。 + +打开/创建文件:~ + + + 如果可能的话在 'current' 当前窗口打开选择的文件。 + + + 在 'tab' 新标签打开选择的文件。 + Open the selected file in a new 'tab'. + + + 在 'vertical' 竖直分割窗口打开选择的文件。 + + , + , + + 在 'horizontal' 水平分割窗口打开选择的文件。 + + + 创建一个新文件和它的父目录。 + +打开多个文件:~ + + + - 标记/取消标记一个被 打开的文件。 + - 标记/取消标记一个被 在它的目录被创建的文件。 + + + - 打开被 标记的文件。 + - 当没有文件被 标记时,使用下列选项打开一个终端对话框: + + 打开被选择的文件: + t - 在新标签页中打开。 + v - 在一个竖直分割窗口中。 + h - 在一个水平分割窗口中。 + r - 在当前窗口中打开。 + i - 在隐藏的缓冲区中。 + x - (可选的)使用 |g:ctrlp_open_func| 中定义的函数。 + + 其它选项 (未显示): + a - 标记匹配窗口中的所有文件。 + d - 改变CtrlP的工作目录到被选择的文件的目录并切换到文件搜索模式。 + +功能按键绑定:~ + + + - 刷新匹配窗口并且清除当前目录的缓存。 + - 从最近最多使用中移除被删除的文件。 + + + - 清除最近最多使用列表。 + - 删除被 标记的最近最多使用条目。 + +粘贴:~ + + , *'ctrlp-pasting'* + + 将剪贴板中的文本粘贴到提示符窗口中。 + + + 打开一个终端对话框来粘贴 ,搜索寄存器的文本,上一次可视 + 化模式的选择,剪贴板或者任何寄存器到提示符面板中。 + +使用 |g:ctrlp_prompt_mappings| 选择你自己的绑定。 + +---------------------------------------- +当焦点在匹配窗口中时(使用 来切换):~ + + a-z + 0-9 + ~^-=;`',.+!@#$%&_(){}[] + 在匹配第一个字符的行中循环。 + +=============================================================================== +输入格式 *ctrlp-input-formats* + +提示符面板的输入格式:~ + +a) 字符串。 + + 例如: 'abc' 被内部理解为 'a[^a]\{-}b[^b]\{-}c' + +b) 在正则表达式模式,输入字符串被按照Vim的正则表达式模式 |pattern| 来对待,不 + 进行任何修改。 + + 例如: 'abc\d*efg' 会被解读为 'abc\d*efg'。 + + 如何启用正则表达式模式参见 |ctrlp-fullregexp| (按键绑定)和 + |g:ctrlp_regexp_search| (选项)。 + +c) 字符串末尾使用一个冒号':'跟随一个Vim命令来在打开那个文件后执行该命令。如果 + 你需要使用':'的字面意思,使用反斜杠转义'\:'。但打开多个文件时,命令会在每 + 个打开文件上执行。 + + 例如: 使用':45'跳转到第45行。 + + 使用':/any\:string'跳转到'any:string'第一次出现的地方。 + + 使用':+setf\ myfiletype|50'来设置文件类型为 'myfiletype',然后跳转 + 到第50行。 + + 使用':diffthis'当打开多个文件时在前四个文件上调用 |:diffthis| 。 + + 参见: Vim的 |++opt| 和 |+cmd|. + +d) 提交两个点号 '..' 来进入上级目录。如果想进入向上多级目录,每多一级使用一个 + 额外的点号: +> + 输入 解释为 + .. ../ + ... ../../ + .... ../../../ +< + 注意: 如果父目录很大并且没有被缓存,可能会很慢。 + + 你可以使用'@cd path/'来改变CtrlP的工作目录为path/。使用'@cd %:h'来改变为当 + 前文件的目录。 + +e) 相似的,提交'/'或者'\'来查找或者跳转到项目的根目录。 + + 如果项目很大,使用版本控制系统的列出命令来寻找文件可能会加速初始化扫描。( + 更多细节参见 |g:ctrlp_user_command| )。 + + 注意: d) 和 e) 只在文件,目录和混合模式生效。 + +f) 输入一个不存在的文件名并且按下 来创建文件。如果使用 标记了一个 + 文件,将会在被标记的文件的目录下创建这个新文件。 + + 例如: 使用 'newdir/newfile.txt' 会创建一个名为'newdir'的目录和一个名为 + 'newfile.txt'的文件。 + + 如果一个条目'some/old/dirs/oldfile.txt'被 标记,然后 'newdir' + 和'newfile.txt'会在'some/old/dirs'下被创建。最终的路径会像下面这样 + 'some/old/dirs/newdir/newfile.txt'. + + 注意: 在Windows下使用 '\' 代替 '/' (如果 |'shellslash'| 选项没有设置)。 + +g) 在文件名模式(使用 切换)下,你可以使用被逗号分隔的一个主要的模式和 + 一个改善的模式。两个模式在正则表达式模式下像(a)或(b)那样工作。 + +h) 使用?打开帮助文件。 + +=============================================================================== +扩展 *ctrlp-extensions* + +扩展是可选的。把它的名字添加到变量g:ctrlp_extensions中来开启扩展: > + let g:ctrlp_extensions = ['tag', 'buffertag', 'quickfix', 'dir', 'rtscript', + \ 'undo', 'line', 'changes', 'mixed', 'bookmarkdir'] +< +扩展的名字在变量中出现的顺序会是在使用命令 切换时扩展在状态栏中出 +现的顺序。 + +可用的扩展:~ + + *:CtrlPTag* + * 标记模式:~ + - 名称: 'tag' + - 命令: ":CtrlPTag" + - 在一个生成的标记文件中搜索标签,跳转到标签定义。使用Vim的 |'tags'| 来指定 + 标签文件的位置和名称。 + 例如: set tags+=doc/tags + + *:CtrlPBufTag* + *:CtrlPBufTagAll* + * 缓冲区标签模式:~ + - 名称: 'buffertag' + - 命令: ":CtrlPBufTag [缓冲区]", + ":CtrlPBufTagAll"。 + - 在当前缓冲区或者所有列出的缓冲区中搜索标签并且跳转到定义。需要 + |exuberant_ctags| 或者兼容的程序。 + + *:CtrlPQuickfix* + * 快速修复模式:~ + - 名称: 'quickfix' + - 命令: ":CtrlPQuickfix" + - 在当前的快速修复错误列表中搜索条目并且跳转过去。 + + *:CtrlPDir* + * 目录模式:~ + - 名称: 'dir' + - 命令: ":CtrlPDir [起始muu]" + - 搜索目录并且将其作为工作目录。 + - 按键绑定: + + 为CtrlP修改工作目录并且保持打开状态。 + + 修改全局的工作目录(退出)。 + + 为当前窗口修改工作目录(退出)。 + + 修改全局工作目录为CtrlP的当前工作目录(退出)。 + + *:CtrlPRTS* + * 运行时脚本模式:~ + - 名称: 'rtscript' + - 命令: ":CtrlPRTS" + - 在运行时路径中寻找文件(vimscripts, docs, snippets...)。 + + *:CtrlPUndo* + * 撤销模式:~ + - 名称: 'undo' + - 命令: ":CtrlPUndo" + - 浏览撤销历史。 + + *:CtrlPLine* + * 行模式:~ + - 名称: 'line' + - 命令: ":CtrlPLine [缓冲区]" + - 在所有列出的缓冲区或者在指定的 [buffer] 缓冲区内搜索一行内容。 + + *:CtrlPChange* + *:CtrlPChangeAll* + * 修改列表模式:~ + - 名称: 'changes' + - 命令: ":CtrlPChange [缓冲区]", + ":CtrlPChangeAll". + - 在当前缓冲区或者在所有列出的缓冲区内搜索最近的修改并跳转。 + + *:CtrlPMixed* + * 混合模式:~ + - 名称: 'mixed' + - 命令: ":CtrlPMixed" + - 同时在文件,缓冲区和最近最多修改中搜索。 + + *:CtrlPBookmarkDir* + *:CtrlPBookmarkDirAdd* + * 书签目录模式:~ + - 名称: 'bookmarkdir' + - 命令: ":CtrlPBookmarkDir", + ":CtrlPBookmarkDirAdd [目录]". + - 搜索一个被书签标记的目录并将其作为工作目录。 + - 按键绑定: + + 为CtrlP修改工作目录并且保持打开状态,并且切换到文件搜索模式。 + + 修改全局的工作目录(退出)。 + + 为当前窗口修改工作目录(退出)。 + + + - 清除书签列表。 + - 删除被 标记的书签条目。 + +---------------------------------------- +缓冲区标记模式选项:~ + + *'g:ctrlp_buftag_ctags_bin'* +如果ctags没有在环境变量中配置,使用该选项来指定它的位置: > + let g:ctrlp_buftag_ctags_bin = '' +< + + *'g:ctrlp_buftag_systemenc'* +将该选项与你的操作系统的编码(非Vim的)保持一致。默认值使用Vim的全局 +|'encoding'| 选项: > + let g:ctrlp_buftag_systemenc = &encoding +< + + *'g:ctrlp_buftag_types'* +使用该选项来在ctags, jsctags...中为指定的文件格式设置参数: > + let g:ctrlp_buftag_types = '' +< +例子: > + let g:ctrlp_buftag_types = { + \ 'erlang' : '--language-force=erlang --erlang-types=drmf', + \ 'javascript' : { + \ 'bin': 'jsctags', + \ 'args': '-f -', + \ }, + \ } +< + +=============================================================================== +自定义 *ctrlp-customization* + +高亮:~ + * CtrlP缓冲区的设置: + CtrlPNoEntries : 当没有匹配被发现时的消息(错误)。 + CtrlPMatch : 匹配模式(标识)。 + CtrlPLinePre : 匹配窗口的行前缀'>'。 + CtrlPPrtBase : 提示符窗口的基础(注释)。 + CtrlPPrtText : 提示符窗口的文本 (|hl-Normal|)。 + CtrlPPrtCursor : 提示符窗口的光标在文本上移动时(常量)。 + + * 在扩展中: + CtrlPTabExtra : 每一行中不匹配的部分(注释)。 + CtrlPBufName : 条目所属的缓冲区名称(|hl-Directory|)。 + CtrlPTagKind : 缓冲区标签模式中标签的类型(|hl-Title|)。 + CtrlPqfLineCol : 快速修复模式中行和列的序号(注释)。 + CtrlPUndoT : 撤销模式的流逝时间(|hl-Directory|)。 + CtrlPUndoBr : 撤销模式的方括号(注释)。 + CtrlPUndoNr : 撤销模式的方括号中的数字(字符串)。 + CtrlPUndoSv : 文件被保存的点(注释)。 + CtrlPUndoPo : 撤销树中的当前位置(|hl-Title|)。 + CtrlPBookmark : 书签的名称(标识)。 + +状态栏:~ + * 高亮组: + CtrlPMode1 : 'file' 或 'path' 或 'line',和当前模式(字符)。 + CtrlPMode2 : 'prt' 或 'win', 'regex',工作目录 |hl-LineNr| 。 + CtrlPStats : 扫描状态(函数)。 + + 重新构建状态栏,参见 |g:ctrlp_status_func| 。 + +=============================================================================== +其它选项 *ctrlp-miscellaneous-configs* + +* 为 |g:ctrlp_user_command| 使用 |wildignore| : +> + function! s:wig2cmd() + " 修改wildignore为空格或者|分隔的组 + " 例如: .aux .out .toc .jpg .bmp .gif + " 或者 .aux$\|.out$\|.toc$\|.jpg$\|.bmp$\|.gif$ + let pats = ['[*\/]*\([?_.0-9A-Za-z]\+\)\([*\/]*\)\(\\\@ 提交) + +* 一个独立的函数,设置项目的根目录为工作目录,如果没有找到根目录的话使用当前文 +* 件的父目录。 +> + function! s:setcwd() + let cph = expand('%:p:h', 1) + if cph =~ '^.\+://' | retu | en + for mkr in ['.git/', '.hg/', '.svn/', '.bzr/', '_darcs/', '.vimprojects'] + let wd = call('find'.(mkr =~ '/$' ? 'dir' : 'file'), [mkr, cph.';']) + if wd != '' | let &acd = 0 | brea | en + endfo + exe 'lc!' fnameescape(wd == '' ? cph : substitute(wd, mkr.'$', '.', '')) + endfunction + + autocmd BufEnter * call s:setcwd() +< +(需要 Vim 7.1.299+) + +* 使用 |count| 来使用同样的按键绑定调用不同的命令: +> + let g:ctrlp_cmd = 'exe "CtrlP".get(["", "Buffer", "MRU"], v:count)' +< + +=============================================================================== +开发人员 *ctrlp-credits* + +由 Kien Nguyen 开发。 在Vim的 |license| 下发行。 + +项目主页: http://kien.github.com/ctrlp.vim +Git仓库: https://github.com/kien/ctrlp.vim +Mercurial仓库: https://bitbucket.org/kien/ctrlp.vim + +------------------------------------------------------------------------------- +感谢所有通过github,bitbucket或电子邮件提供想法,报告bug或者帮助debugging的人。 + +特别感谢:~ + + * Woojong Koh + * Simon Ruderich + * Yasuhiro Matsumoto + * Ken Earley + * Kyo Nagashima + * Zak Johnson + * Diego Viola + * Piet Delport + * Thibault Duplessis + * Kent Sibilev + * Tacahiroy + * Luca Pette + * Seth Fowler + * Lowe Thiderman + * Christopher Fredén + * Zahary Karadjov + * Jo De Boeck + * Rudi Grinberg + * Timothy Mellor + +=============================================================================== +更新日志 *ctrlp-changelog* + + + 结合 *g:ctrlp_match_window_bottom* *g:ctrlp_match_window_reversed* 和 + *g:ctrlp_max_height* 到 |g:ctrlp_match_window| 。 + + 新选项: |g:ctrlp_match_window| 。 + +在2012/11/30之前~ + + + 新选项: |g:ctrlp_abbrev|, + |g:ctrlp_key_loop|, + |g:ctrlp_open_func|, + |g:ctrlp_tabpage_position|, + |g:ctrlp_mruf_save_on_update| + + 重命名: + *g:ctrlp_dotfiles* -> |g:ctrlp_show_hidden| 。 + + 修改 |g:ctrlp_switch_buffer| 和 |g:ctrlp_working_path_mode|的类型 + (旧值仍然工作)。 + + 当 |g:ctrlp_user_command| 是一个字典时,为其增加一个新的键: 'ignore'。 + +在2012/06/15之前~ + + + |g:ctrlp_follow_symlinks| 的新值: 2。 + + |g:ctrlp_open_multiple_files| 的新值: 'j'。 + + 允许使用 , , 打开被 标记的文件。 + + 扩展 '..' (|ctrlp-input-formats| (d)) + + 新的输入格式: '@cd' (|ctrlp-input-formats| (d)) + +在2012/04/30之前~ + + + 新选项: |g:ctrlp_mruf_default_order| + + 新特性: 被书签标记的目录的扩展。 + + 新命令: |:CtrlPBookmarkDir| + |:CtrlPBookmarkDirAdd| + +在2012/04/15之前~ + + + 新选项: |g:ctrlp_buffer_func|,CtrlP缓冲区的回调函数。 + + 移除 : g:ctrlp_mruf_last_entered,使其作为最近最多使用的默认行为。 + + 新命令: |:CtrlPLastMode|,以上一次使用的模式打开CtrlP。 + |:CtrlPMixed|,在文件,缓冲区和最近最多使用中搜索。 + +在2012/03/31之前~ + + + 新选项: |g:ctrlp_default_input|, 进入CtrlP后的默认输入。 + |g:ctrlp_match_func|,允许使用自定义的模糊查找工具。 + + 重命名: + *ClearCtrlPCache* -> |CtrlPClearCache| + *ClearAllCtrlPCaches* -> |CtrlPClearAllCaches| + *ResetCtrlP* -> |CtrlPReload| + +在2012/03/02之前~ + + + 重命名: + *g:ctrlp_regexp_search* -> |g:ctrlp_regexp|, + *g:ctrlp_dont_split* -> |g:ctrlp_reuse_window|, + *g:ctrlp_jump_to_buffer* -> |g:ctrlp_switch_buffer|。 + + 重命名和微调: + *g:ctrlp_open_multi* -> |g:ctrlp_open_multiple_files|。 + + 过时 *g:ctrlp_highlight_match* + + 扩展 |g:ctrlp_user_command| 支持多个命令。 + + 新选项: |g:ctrlp_mruf_last_entered| 修改最近最多使用为最近进入。 + +在2012/01/15之前~ + + + 新按键绑定: 交换 . 现在用来补全在当前工作目录内的目 + 录名。 + + 新选项: |g:ctrlp_arg_map| 使 可以接收一个参数。 + |g:ctrlp_status_func| 自定义状态栏。 + |g:ctrlp_mruf_relative| 在当前工作目录内显示最近最多使用。 + + 扩展 g:ctrlp_open_multi 增加新选项值: tr, hr, vr。 + + 扩展 |g:ctrlp_custom_ignore| 指定过滤目录,文件和链接。 + +在2012/01/05之前~ + + + 新特性: 缓冲区标记扩展。 + + 新命令: |:CtrlPBufTag|, |:CtrlPBufTagAll|。 + + 新选项: |g:ctrlp_cmd|, + |g:ctrlp_custom_ignore| + +在2011/11/30之前~ + + + 新特性: 标签,快速修复和目录扩展。 + + 新命令: |:CtrlPTag|, |:CtrlPQuickfix|, |:CtrlPDir|。 + + 新选项: |g:ctrlp_use_migemo|, + |g:ctrlp_lazy_update|, + |g:ctrlp_follow_symlinks| + +在2011/11/13之前~ + + + 新的特殊输入: '/' 和 '\' 查找根目录 (|ctrlp-input-formats| (e)) + + 移除 ctrlp#SetWorkingPath()。 + + 移除 *g:ctrlp_mru_files* ,使最近最多使用模式变为永久的。 + + 扩展 g:ctrlp_open_multi,添加打开文件的新方式。 + + 新选项: g:ctrlp_dont_split, + |g:ctrlp_mruf_case_sensitive| + +在2011/10/30之前~ + + + 新特性: 支持自定义扩展。 + 也会从最近最多使用列表中移除不存在的文件。 + + 新选项: g:ctrlp_jump_to_buffer + +在2011/10/12之前~ + + + 新特性: 打开多个文件。 + 传递Vim的 |++opt| 和 |+cmd| 到新打开的文件 + (|ctrlp-input-formats| (c)) + 为 |:CtrlP| [起始目录]自动补全每个目录 + + 新按键绑定: 标记/取消标记一个被 打开的文件。 + 打开所有被标记的文件。 + + 新选项: g:ctrlp_open_multi + + 移除 *g:ctrlp_persistent_input* *g:ctrlp_live_update* and 。 + +在2011/09/29之前~ + + + 新按键绑定: , 输入历史中的前一个/后一个字符串。 + 创建一个新的文件和它的父目录。 + + 新选项: |g:ctrlp_open_new_file|, + |g:ctrlp_max_history| + + 添加一个新的在横向分割窗口打开的绑定: + +在2011/09/19之前~ + + + 新命令: ResetCtrlP + + 新选项: |g:ctrlp_max_files|, + |g:ctrlp_max_depth|, + g:ctrlp_live_update + + 新按键绑定: + +在2011/09/12之前~ + + + 添加在匹配窗口内循环匹配行的功能。 + + 扩展 g:ctrlp_persistent_input的行为 + + 扩展 |:CtrlP| 的行为 + + 新选项: |g:ctrlp_dotfiles|, + |g:ctrlp_clear_cache_on_exit|, + g:ctrlp_highlight_match, + |g:ctrlp_user_command| + + 新的特殊输入: '..' (|ctrlp-input-formats| (d)) + + 新按键绑定: 。 + + 新命令: |:CtrlPCurWD|, + |:CtrlPCurFile|, + |:CtrlPRoot| + + + 新特性: 在最近最常使用的文件列表中搜索 + + 新按键绑定: 。 + + 扩展 的行为。 + + 新选项: g:ctrlp_mru_files, + |g:ctrlp_mruf_max|, + |g:ctrlp_mruf_exclude|, + |g:ctrlp_mruf_include| + + 新命令: |:CtrlPMRU| + +第一版发布于: 2011/09/06~ + +=============================================================================== +vim:ft=help:et:ts=2:sw=2:sts=2:norl From fd2dc8e8e49ba9ce62319f77db2a09dd923b9d4b Mon Sep 17 00:00:00 2001 From: codepiano Date: Mon, 9 Dec 2013 01:43:41 +0800 Subject: [PATCH 06/67] rename the ctrlp_cn.txt to ctrlp.cnx --- doc/{ctrlp_cn.txt => ctrlp.cnx} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename doc/{ctrlp_cn.txt => ctrlp.cnx} (100%) diff --git a/doc/ctrlp_cn.txt b/doc/ctrlp.cnx similarity index 100% rename from doc/ctrlp_cn.txt rename to doc/ctrlp.cnx From b844bf8745f895753e95480d24fc5daec09d75dc Mon Sep 17 00:00:00 2001 From: codepiano Date: Mon, 16 Dec 2013 23:37:11 +0800 Subject: [PATCH 07/67] fix translate errors --- doc/ctrlp.cnx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/ctrlp.cnx b/doc/ctrlp.cnx index 45ac6480..bbb5e8eb 100644 --- a/doc/ctrlp.cnx +++ b/doc/ctrlp.cnx @@ -74,8 +74,8 @@ OPTIONS *ctrlp-options* |ctrlp_use_migemo|............为日语文件名启用Migemo模式。 |ctrlp_prompt_mappings|.......改变提示符面板内部的按键绑定。 - 最近最常使用模式: - |ctrlp_mruf_max|..............记录的最近最常最多使用的最大数据。 + 最近最多使用模式: + |ctrlp_mruf_max|..............记录的最近最多使用的最大数据。 |ctrlp_mruf_exclude|..........需要被排除的文件。 |ctrlp_mruf_include|..........需要被记录的文件。 |ctrlp_mruf_relative|.........只显示在工作目录内的最近最多使用。 @@ -218,7 +218,7 @@ OPTIONS *ctrlp-options* 注意: 当在CtrlP中时你可以使用 来快速的清除缓存。 *'g:ctrlp_clear_cache_on_exit'* -设置该选项为0通过退出Vim时不删除缓存文件来启用跨回话的缓存: > +设置该选项为0通过退出Vim时不删除缓存文件来启用跨会话的缓存: > let g:ctrlp_clear_cache_on_exit = 1 < From abc936aa3cae5582ea58adb92c7c89ac066e29cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rory=20O=E2=80=99Kane?= Date: Wed, 26 Mar 2014 02:13:09 -0400 Subject: [PATCH 08/67] Make README screenshot narrower to fit MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Make README screenshot narrower so it fits on the GitHub project home page The current screenshot as displayed on https://github.com/kien/ctrlp.vim is squished to fit within 722px, introducing aliasing and making the screenshot hard to read. This updated image is 720px, so it will fit, and provide a better first impression of ctrlp.vim to people visiting the project page. I produced this screenshot in Photoshop by effectively deleting some of the empty space in the middle. The window in the image might not be a realistically-sized one – its width might not be a multiple of the character cell width – but nobody will notice. --- readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme.md b/readme.md index bcd07c7f..8b85bde6 100644 --- a/readme.md +++ b/readme.md @@ -83,6 +83,6 @@ Check `:help ctrlp-options` for other options. ## Installation Use your favorite method or check the homepage for a [quick installation guide][3]. -[1]: http://i.imgur.com/yIynr.png +[1]: http://i.imgur.com/aOcwHwt.png [2]: https://github.com/kien/ctrlp.vim/tree/extensions [3]: http://kien.github.com/ctrlp.vim#installation From f04b5619b709e7e3ea0d56cff6769facdd3b7c07 Mon Sep 17 00:00:00 2001 From: Angelo Olivera Date: Mon, 21 Apr 2014 11:12:04 -0700 Subject: [PATCH 09/67] Improve wording for ctrlp_working_path_mode Fixes #397 --- doc/ctrlp.txt | 11 +++++------ readme.md | 5 +++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/doc/ctrlp.txt b/doc/ctrlp.txt index e697b937..e06af69a 100644 --- a/doc/ctrlp.txt +++ b/doc/ctrlp.txt @@ -181,13 +181,12 @@ variable: > 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: + a - the directory of the current file, unless it is a subdirectory of the cwd + r - the nearest ancestor of the current file that contains one of these + directories or files: .git .hg .svn .bzr _darcs - 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. + w - modifier to "r": start search from the cwd instead of the current file's + directory 0 or - disable this feature. Note #1: if "a" or "c" is included with "r", use the behavior of "a" or "c" (as diff --git a/readme.md b/readme.md index bcd07c7f..373e7259 100644 --- a/readme.md +++ b/readme.md @@ -51,8 +51,9 @@ Use `:diffthis` when opening multiple files to run `:diffthis` on the first 4 fi ``` `'c'` - the directory of the current file. - `'r'` - the nearest ancestor that contains one of these directories or files: `.git` `.hg` `.svn` `.bzr` `_darcs` - `'a'` - like c, but only if the current working directory outside of CtrlP is not a direct ancestor of the directory of the current file. + `'a'` - the directory of the current file, unless it is a subdirectory of the cwd + `'r'` - the nearest ancestor of the current file that contains one of these directories or files: `.git` `.hg` `.svn` `.bzr` `_darcs` + `'w'` - modifier to "r": start search from the cwd instead of the current file's directory `0` or `''` (empty string) - disable this feature. Define additional root markers with the `g:ctrlp_root_markers` option. From 11fe3e1dadca0f9fd41c5ec6f237b25e3ffc6260 Mon Sep 17 00:00:00 2001 From: d11wtq Date: Sun, 15 Jun 2014 09:01:11 +0000 Subject: [PATCH 10/67] Add function ctrlp#clearmarkedlist() --- autoload/ctrlp.vim | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/autoload/ctrlp.vim b/autoload/ctrlp.vim index 19ac1463..a76425e3 100644 --- a/autoload/ctrlp.vim +++ b/autoload/ctrlp.vim @@ -2206,6 +2206,10 @@ fu! ctrlp#getmarkedlist() retu exists('s:marked') ? values(s:marked) : [] endf +fu! ctrlp#clearmarkedlist() + let s:marked = {} +endf + fu! ctrlp#exit() cal s:PrtExit() endf From bf8a824ef8506747dcd51fcc3803e57fbe3d0e31 Mon Sep 17 00:00:00 2001 From: "Emily St." Date: Fri, 11 Jul 2014 17:24:12 -0700 Subject: [PATCH 11/67] Add support for Scala Buffer tags supported includes traits, methods, types, classes, objects, packages. In order to use this with Exuberant Ctags, the following needs to be added to ~/.ctags: --langdef=Scala --langmap=Scala:.scala --regex-scala=/^[ \t]*((abstract|final|sealed|implicit|lazy)[ \t]*)*(private|protected)?[ \t]*class[ \t]+([a-zA-Z0-9_]+)/\4/c,classes/ --regex-scala=/^[ \t]*((abstract|final|sealed|implicit|lazy)[ \t]*)*(private|protected)?[ \t]*object[ \t]+([a-zA-Z0-9_]+)/\4/c,objects/ --regex-scala=/^[ \t]*((abstract|final|sealed|implicit|lazy)[ \t]*)*(private|protected)?[ \t]*case class[ \t]+([a-zA-Z0-9_]+)/\4/c,case classes/ --regex-scala=/^[ \t]*((abstract|final|sealed|implicit|lazy)[ \t]*)*(private|protected)?[ \t]*case object[ \t]+([a-zA-Z0-9_]+)/\4/c,case objects/ --regex-scala=/^[ \t]*((abstract|final|sealed|implicit|lazy)[ \t]*)*(private|protected)?[ \t]*trait[ \t]+([a-zA-Z0-9_]+)/\4/t,traits/ --regex-scala=/^[ \t]*type[ \t]+([a-zA-Z0-9_]+)/\1/T,types/ --regex-scala=/^[ \t]*((abstract|final|sealed|implicit|lazy)[ \t]*)*def[ \t]+([a-zA-Z0-9_]+)/\3/m,methods/ --regex-scala=/^[ \t]*((abstract|final|sealed|implicit|lazy)[ \t]*)*val[ \t]+([a-zA-Z0-9_]+)/\3/l,constants/ --regex-scala=/^[ \t]*((abstract|final|sealed|implicit|lazy)[ \t]*)*var[ \t]+([a-zA-Z0-9_]+)/\3/l,variables/ --regex-scala=/^[ \t]*package[ \t]+([a-zA-Z0-9_.]+)/\1/p,packages/ --- autoload/ctrlp/buffertag.vim | 1 + 1 file changed, 1 insertion(+) diff --git a/autoload/ctrlp/buffertag.vim b/autoload/ctrlp/buffertag.vim index a38cad56..57f59ab6 100644 --- a/autoload/ctrlp/buffertag.vim +++ b/autoload/ctrlp/buffertag.vim @@ -73,6 +73,7 @@ let s:types = { \ 'sh' : '%ssh%ssh%sf', \ 'csh' : '%ssh%ssh%sf', \ 'zsh' : '%ssh%ssh%sf', + \ 'scala' : '%sscala%sscala%sctTmlp', \ 'slang' : '%sslang%sslang%snf', \ 'sml' : '%ssml%ssml%secsrtvf', \ 'sql' : '%ssql%ssql%scFPrstTvfp', From 2f3055e206644f8de6f7a5ce297e655f48d3c6af Mon Sep 17 00:00:00 2001 From: ludovicchabant Date: Wed, 23 Jul 2014 13:01:30 -0700 Subject: [PATCH 12/67] Add ability to specify a custom ignore function, instead of just patterns. --- autoload/ctrlp.vim | 14 +++++++++++--- doc/ctrlp.txt | 9 +++++++++ 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/autoload/ctrlp.vim b/autoload/ctrlp.vim index 19ac1463..a5906873 100644 --- a/autoload/ctrlp.vim +++ b/autoload/ctrlp.vim @@ -1532,9 +1532,17 @@ fu! ctrlp#dirnfile(entries) endf fu! s:usrign(item, type) - retu s:igntype == 1 ? a:item =~ s:usrign - \ : s:igntype == 4 && has_key(s:usrign, a:type) && s:usrign[a:type] != '' - \ ? a:item =~ s:usrign[a:type] : 0 + if s:igntype == 1 | retu a:item =~ s:usrign | end + if s:igntype == 4 + if has_key(s:usrign, a:type) && s:usrign[a:type] != '' + \ && a:item =~ s:usrign[a:type] + retu 1 + elsei has_key(s:usrign, 'func') && s:usrign['func'] != '' + \ && call(s:usrign['func'], [a:item, a:type]) + retur 1 + end + end + retu 0 endf fu! s:samerootsyml(each, isfile, cwd) diff --git a/doc/ctrlp.txt b/doc/ctrlp.txt index e697b937..e15fe5a7 100644 --- a/doc/ctrlp.txt +++ b/doc/ctrlp.txt @@ -261,6 +261,9 @@ Examples: > let g:ctrlp_custom_ignore = { \ 'file': '\v(\.cpp|\.h|\.hh|\.cxx)@ let g:ctrlp_max_files = 10000 From 87d559c9aae0fd089315e4e0d29731e9973d0674 Mon Sep 17 00:00:00 2001 From: Chronial Date: Sat, 26 Jul 2014 17:51:24 +0200 Subject: [PATCH 13/67] Check shell in Windows before assuming cmd.exe In Windows, some users set the Cygwin shell as their Vim shell, consider this before rewriting `cd` calls. Checking if `shellcmdflag` contains a backslash should catch all true windows shells. You can also check if &shell contains `sh`, but this seems more robust. --- autoload/ctrlp.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autoload/ctrlp.vim b/autoload/ctrlp.vim index 19ac1463..9a379d05 100644 --- a/autoload/ctrlp.vim +++ b/autoload/ctrlp.vim @@ -387,7 +387,7 @@ fu! s:UserCmd(lscmd) if exists('+ssl') && &ssl let [ssl, &ssl, path] = [&ssl, 0, tr(path, '/', '\')] en - if has('win32') || has('win64') + if (has('win32') || has('win64')) && match(&shellcmdflag, "/") != -1 let lscmd = substitute(lscmd, '\v(^|\&\&\s*)\zscd (/d)@!', 'cd /d ', '') en let path = exists('*shellescape') ? shellescape(path) : path From 7ceaa81345fb2485e50c12dfc1ae8d738cd909eb Mon Sep 17 00:00:00 2001 From: Nuno Santos Date: Mon, 28 Jul 2014 12:11:25 +0200 Subject: [PATCH 14/67] Added support for custom ancestors: g:ctrlp_custom_ancestors. --- autoload/ctrlp.vim | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/autoload/ctrlp.vim b/autoload/ctrlp.vim index 19ac1463..0e7f9f8b 100644 --- a/autoload/ctrlp.vim +++ b/autoload/ctrlp.vim @@ -58,6 +58,7 @@ let [s:pref, s:bpref, s:opts, s:new_opts, s:lc_opts] = \ 'buffer_func': ['s:buffunc', {}], \ 'by_filename': ['s:byfname', 0], \ 'custom_ignore': ['s:usrign', s:ignore()], + \ 'custom_ancestors': ['s:custom_markers', []], \ 'default_input': ['s:deftxt', 0], \ 'dont_split': ['s:nosplit', 'netrw'], \ 'dotfiles': ['s:showhidden', 0], @@ -968,7 +969,7 @@ fu! s:SetWD(args) cal ctrlp#setdir(s:crfpath) en if pmode =~ 'r' || pmode == 2 - let markers = ['.git', '.hg', '.svn', '.bzr', '_darcs'] + let markers = ['.git', '.hg', '.svn', '.bzr', '_darcs'] + s:custom_markers let spath = pmode =~ 'd' ? s:dyncwd : pmode =~ 'w' ? s:cwd : s:crfpath if type(s:rmarkers) == 3 && !empty(s:rmarkers) if s:findroot(spath, s:rmarkers, 0, 0) != [] | retu | en From daf7c47d9ec14a0e5cda3f7d12ea4596302dae57 Mon Sep 17 00:00:00 2001 From: Amadeus Demarzi Date: Thu, 8 May 2014 18:48:17 -0700 Subject: [PATCH 15/67] Added CtrlPMark highlight group This creates the ability to add custom highlighting to CtrlP signs/marks if someone wishes to change them. It links back to the Search group to maintain backwards compatibility. --- autoload/ctrlp.vim | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/autoload/ctrlp.vim b/autoload/ctrlp.vim index 19ac1463..50e85420 100644 --- a/autoload/ctrlp.vim +++ b/autoload/ctrlp.vim @@ -283,7 +283,8 @@ fu! s:Open() sil! exe 'let s:glb_'.ke.' = &'.ke.' | let &'.ke.' = '.string(va) en | endfo if s:opmul != '0' && has('signs') - sign define ctrlpmark text=+> texthl=Search + sign define ctrlpmark text=+> texthl=CtrlPMark + hi def link CtrlPMark Search en cal s:setupblank() endf From 802f5a8ac3ad7183b7e5145baddd50c344f4d26a Mon Sep 17 00:00:00 2001 From: mattn Date: Fri, 8 Aug 2014 11:24:01 +0900 Subject: [PATCH 16/67] Drop migemo --- autoload/ctrlp.vim | 20 -------------------- doc/ctrlp.cnx | 7 ------- doc/ctrlp.txt | 7 ------- 3 files changed, 34 deletions(-) diff --git a/autoload/ctrlp.vim b/autoload/ctrlp.vim index 5b59a878..59575341 100644 --- a/autoload/ctrlp.vim +++ b/autoload/ctrlp.vim @@ -87,7 +87,6 @@ let [s:pref, s:bpref, s:opts, s:new_opts, s:lc_opts] = \ 'status_func': ['s:status', {}], \ 'tabpage_position': ['s:tabpage', 'ac'], \ 'use_caching': ['s:caching', 1], - \ 'use_migemo': ['s:migemo', 0], \ 'user_command': ['s:usrcmd', ''], \ 'working_path_mode': ['s:pathmode', 'ra'], \ }, { @@ -499,9 +498,6 @@ endf fu! s:SplitPattern(str) let str = a:str - if s:migemo && s:regexp && len(str) > 0 && executable('cmigemo') - let str = s:migemo(str) - en let s:savestr = str if s:regexp let pat = s:regexfilter(str) @@ -1948,22 +1944,6 @@ fu! s:getinput(...) retu spi == 'c' ? prt[0] : join(prt, '') endf -fu! s:migemo(str) - let [str, rtp] = [a:str, s:fnesc(&rtp, 'g')] - let dict = s:glbpath(rtp, printf("dict/%s/migemo-dict", &enc), 1) - if !len(dict) - let dict = s:glbpath(rtp, "dict/migemo-dict", 1) - en - if len(dict) - let [tokens, str, cmd] = [split(str, '\s'), '', 'cmigemo -v -w %s -d %s'] - for token in tokens - let rtn = system(printf(cmd, shellescape(token), shellescape(dict))) - let str .= !v:shell_error && strlen(rtn) > 0 ? '.*'.rtn : token - endfo - en - retu str -endf - fu! s:strwidth(str) retu exists('*strdisplaywidth') ? strdisplaywidth(a:str) : strlen(a:str) endf diff --git a/doc/ctrlp.cnx b/doc/ctrlp.cnx index bbb5e8eb..d1b3a2fb 100644 --- a/doc/ctrlp.cnx +++ b/doc/ctrlp.cnx @@ -71,7 +71,6 @@ OPTIONS *ctrlp-options* |ctrlp_default_input|.........为提示符面板提供一个种子。 |ctrlp_abbrev|................输入缩写。 |ctrlp_key_loop|..............为多字节输入开启输入事件循环。 - |ctrlp_use_migemo|............为日语文件名启用Migemo模式。 |ctrlp_prompt_mappings|.......改变提示符面板内部的按键绑定。 最近最多使用模式: @@ -479,12 +478,6 @@ OPTIONS *ctrlp-options* let g:ctrlp_prompt_mappings = { 'ToggleKeyLoop()': [''] } < - *'g:ctrlp_use_migemo'* -设置该选项为1将为日文文件名使用Migemo模式。Migemo搜索只在正则模式下有效。 使 -用空格分割单词来分离模式: > - let g:ctrlp_use_migemo = 0 -< - *'g:ctrlp_prompt_mappings'* 使用该选项来自定义CtrlP的提示窗口内的按键绑定为你喜欢的方式。你只需要保留你改 变值(在[]内部)的行: > diff --git a/doc/ctrlp.txt b/doc/ctrlp.txt index e697b937..4e0ed5f0 100644 --- a/doc/ctrlp.txt +++ b/doc/ctrlp.txt @@ -63,7 +63,6 @@ Overview:~ |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: @@ -497,12 +496,6 @@ Note #2: you can toggle this feature inside the prompt with a custom mapping: > let g:ctrlp_prompt_mappings = { 'ToggleKeyLoop()': [''] } < - *'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: > - let g:ctrlp_use_migemo = 0 -< - *'g:ctrlp_prompt_mappings'* Use this to customize the mappings inside CtrlP's prompt to your liking. You only need to keep the lines that you've changed the values (inside []): > From 3837950531263dc945f2bfde7c33c9ea77b50b4f Mon Sep 17 00:00:00 2001 From: d11wtq Date: Fri, 8 Aug 2014 02:33:59 +0000 Subject: [PATCH 17/67] Update URLs in README to point to new repo --- readme.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/readme.md b/readme.md index 8b85bde6..882bfe8b 100644 --- a/readme.md +++ b/readme.md @@ -84,5 +84,5 @@ Check `:help ctrlp-options` for other options. Use your favorite method or check the homepage for a [quick installation guide][3]. [1]: http://i.imgur.com/aOcwHwt.png -[2]: https://github.com/kien/ctrlp.vim/tree/extensions -[3]: http://kien.github.com/ctrlp.vim#installation +[2]: https://github.com/ctrlpvim/ctrlp.vim/tree/extensions +[3]: http://ctrlpvim.github.com/ctrlp.vim#installation From b94d8b41cae351491e553d9f5a413073ac1b1975 Mon Sep 17 00:00:00 2001 From: Albert Lee Date: Thu, 6 Mar 2014 11:38:52 -0500 Subject: [PATCH 18/67] Improve g:ctrlp_working_path_mode Support ordered processing of multiple g:ctrlp_working_path_mode specifications Clarify g:ctrlp_working_path_mode semantics in readme.md --- autoload/ctrlp.vim | 45 +++++++++++++++++++++++++++++---------------- readme.md | 15 ++++++++------- 2 files changed, 37 insertions(+), 23 deletions(-) diff --git a/autoload/ctrlp.vim b/autoload/ctrlp.vim index 59575341..37ba70bd 100644 --- a/autoload/ctrlp.vim +++ b/autoload/ctrlp.vim @@ -957,23 +957,19 @@ fu! s:SetWD(args) 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 pmodes = 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' || ( 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 - if pmode =~ 'r' || pmode == 2 - let markers = ['.git', '.hg', '.svn', '.bzr', '_darcs'] + s:custom_markers - let spath = pmode =~ 'd' ? s:dyncwd : pmode =~ 'w' ? s:cwd : s:crfpath - if type(s:rmarkers) == 3 && !empty(s:rmarkers) - if s:findroot(spath, s:rmarkers, 0, 0) != [] | retu | en - cal filter(markers, 'index(s:rmarkers, v:val) < 0') - en - cal s:findroot(spath, markers, 0, 0) - en + if (!type(pmodes)) + let pmodes = + \ pmodes == 0 ? '' : + \ pmodes == 1 ? 'a' : + \ pmodes == 2 ? 'r' : + \ 'c' + en + let spath = pmodes =~ 'd' ? s:dyncwd : pmodes =~ 'w' ? s:cwd : s:crfpath + for pmode in split(pmodes, '\zs') + if ctrlp#setpathmode(pmode, spath) | retu | en + endfo endf " * AcceptSelection() {{{1 fu! ctrlp#acceptfile(...) @@ -1584,6 +1580,23 @@ fu! s:findroot(curr, mark, depth, type) retu [] endf +fu! ctrlp#setpathmode(pmode, ...) + if a:pmode == 'c' || ( a:pmode == 'a' && stridx(s:crfpath, s:cwd) < 0 ) + if exists('+acd') | let [s:glb_acd, &acd] = [&acd, 0] | en + cal ctrlp#setdir(s:crfpath) + retu 1 + elsei a:pmode == 'r' + let spath = a:0 ? a:1 : s:crfpath + let markers = ['.git', '.hg', '.svn', '.bzr', '_darcs'] + if type(s:rmarkers) == 3 && !empty(s:rmarkers) + if s:findroot(spath, s:rmarkers, 0, 0) != [] | retu 1 | en + cal filter(markers, 'index(s:rmarkers, v:val) < 0') + en + if s:findroot(spath, markers, 0, 0) != [] | retu 1 | en + en + retu 0 +endf + fu! ctrlp#setdir(path, ...) let cmd = a:0 ? a:1 : 'lc!' sil! exe cmd s:fnesc(a:path, 'c') diff --git a/readme.md b/readme.md index 882bfe8b..8f7ac959 100644 --- a/readme.md +++ b/readme.md @@ -32,8 +32,8 @@ Check `:help ctrlp-commands` and `:help ctrlp-extensions` for other commands. Run `:help ctrlp-mappings` or submit `?` in CtrlP for more mapping help. * Submit two or more dots `..` to go up the directory tree by one or multiple levels. -* End the input string with a colon `:` followed by a command to execute it on the opening file(s): -Use `:25` to jump to line 25. +* End the input string with a colon `:` followed by a command to execute it on the opening file(s): +Use `:25` to jump to line 25. Use `:diffthis` when opening multiple files to run `:diffthis` on the first 4 files. ## Basic Options @@ -44,17 +44,18 @@ Use `:diffthis` when opening multiple files to run `:diffthis` on the first 4 fi let g:ctrlp_cmd = 'CtrlP' ``` -* When invoked, unless a starting directory is specified, CtrlP will set its local working directory according to this variable: +* When invoked without an explicit starting directory, CtrlP will set its local working directory according to this variable: ```vim let g:ctrlp_working_path_mode = 'ra' ``` - `'c'` - the directory of the current file. - `'r'` - the nearest ancestor that contains one of these directories or files: `.git` `.hg` `.svn` `.bzr` `_darcs` - `'a'` - like c, but only if the current working directory outside of CtrlP is not a direct ancestor of the directory of the current file. - `0` or `''` (empty string) - disable this feature. + `'c'` - use the parent directory of the current file. + `'a'` - use the parent directory of the current file if it is not a descendant of the current working directory outside of CtrlP. + `'r'` - use the nearest ancestor of the current file that contains one of these markers: `.git` `.hg` `.svn` `.bzr` `_darcs` + `0` or `''` (empty string) - use the current working directory outside of CtrlP. + If more than one mode is specified, they will be tried in order until a directory is located. Define additional root markers with the `g:ctrlp_root_markers` option. * Exclude files and directories using Vim's `wildignore` and CtrlP's own `g:ctrlp_custom_ignore`: From 3532f9874044536e9ad75f786a90e22d720ff6fb Mon Sep 17 00:00:00 2001 From: mattn Date: Fri, 8 Aug 2014 12:38:25 +0900 Subject: [PATCH 19/67] Retab --- autoload/ctrlp.vim | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/autoload/ctrlp.vim b/autoload/ctrlp.vim index ef568322..9689e9f5 100644 --- a/autoload/ctrlp.vim +++ b/autoload/ctrlp.vim @@ -1526,17 +1526,17 @@ fu! ctrlp#dirnfile(entries) endf fu! s:usrign(item, type) - if s:igntype == 1 | retu a:item =~ s:usrign | end - if s:igntype == 4 - if has_key(s:usrign, a:type) && s:usrign[a:type] != '' - \ && a:item =~ s:usrign[a:type] - retu 1 - elsei has_key(s:usrign, 'func') && s:usrign['func'] != '' - \ && call(s:usrign['func'], [a:item, a:type]) - retur 1 - end - end - retu 0 + if s:igntype == 1 | retu a:item =~ s:usrign | end + if s:igntype == 4 + if has_key(s:usrign, a:type) && s:usrign[a:type] != '' + \ && a:item =~ s:usrign[a:type] + retu 1 + elsei has_key(s:usrign, 'func') && s:usrign['func'] != '' + \ && call(s:usrign['func'], [a:item, a:type]) + retur 1 + end + end + retu 0 endf fu! s:samerootsyml(each, isfile, cwd) @@ -2210,7 +2210,7 @@ fu! ctrlp#getmarkedlist() endf fu! ctrlp#clearmarkedlist() - let s:marked = {} + let s:marked = {} endf fu! ctrlp#exit() From 27b6f158fc24281ac9a2529fcf7471f0285fd271 Mon Sep 17 00:00:00 2001 From: mattn Date: Fri, 8 Aug 2014 12:40:49 +0900 Subject: [PATCH 20/67] Support ctrlp_custom_ignore as function ref --- autoload/ctrlp.vim | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/autoload/ctrlp.vim b/autoload/ctrlp.vim index 9689e9f5..d256ec32 100644 --- a/autoload/ctrlp.vim +++ b/autoload/ctrlp.vim @@ -1527,13 +1527,17 @@ endf fu! s:usrign(item, type) if s:igntype == 1 | retu a:item =~ s:usrign | end - if s:igntype == 4 + if s:igntype == 2 + if call(s:usrign, [a:item, a:type]) + retu 1 + end + elsei s:igntype == 4 if has_key(s:usrign, a:type) && s:usrign[a:type] != '' \ && a:item =~ s:usrign[a:type] retu 1 elsei has_key(s:usrign, 'func') && s:usrign['func'] != '' \ && call(s:usrign['func'], [a:item, a:type]) - retur 1 + retu 1 end end retu 0 From 498e35fa492371a3540586ce2d576bc45ba18c4b Mon Sep 17 00:00:00 2001 From: Nuno Santos Date: Fri, 8 Aug 2014 09:56:42 +0200 Subject: [PATCH 21/67] Remove custom_ancestors since root_markers does the same thing. Update the README to include an example. --- autoload/ctrlp.vim | 1 - readme.md | 7 ++++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/autoload/ctrlp.vim b/autoload/ctrlp.vim index d256ec32..2d79bb70 100644 --- a/autoload/ctrlp.vim +++ b/autoload/ctrlp.vim @@ -58,7 +58,6 @@ let [s:pref, s:bpref, s:opts, s:new_opts, s:lc_opts] = \ 'buffer_func': ['s:buffunc', {}], \ 'by_filename': ['s:byfname', 0], \ 'custom_ignore': ['s:usrign', s:ignore()], - \ 'custom_ancestors': ['s:custom_markers', []], \ 'default_input': ['s:deftxt', 0], \ 'dont_split': ['s:nosplit', 'netrw'], \ 'dotfiles': ['s:showhidden', 0], diff --git a/readme.md b/readme.md index 8f7ac959..ce47e946 100644 --- a/readme.md +++ b/readme.md @@ -55,8 +55,13 @@ Use `:diffthis` when opening multiple files to run `:diffthis` on the first 4 fi `'r'` - use the nearest ancestor of the current file that contains one of these markers: `.git` `.hg` `.svn` `.bzr` `_darcs` `0` or `''` (empty string) - use the current working directory outside of CtrlP. + If none of the default markers (`.git` `.hg` `.svn` `.bzr` `_darcs`) are present in a project, you can define additional ones with `g:ctrlp_root_markers`: + + ```vim + let g:ctrlp_root_markers = ['pom.xml', '.p4ignore'] + ``` + If more than one mode is specified, they will be tried in order until a directory is located. - Define additional root markers with the `g:ctrlp_root_markers` option. * Exclude files and directories using Vim's `wildignore` and CtrlP's own `g:ctrlp_custom_ignore`: From 417ab865637acdc8f41c7ffa009c828bac028f54 Mon Sep 17 00:00:00 2001 From: Aaron Jensen Date: Fri, 8 Aug 2014 08:01:41 -0700 Subject: [PATCH 22/67] update matcher to match that of ctrlp-cmatcher --- autoload/ctrlp.vim | 60 +++++++++++++++++++++++++++++++--------------- 1 file changed, 41 insertions(+), 19 deletions(-) diff --git a/autoload/ctrlp.vim b/autoload/ctrlp.vim index 454ff2e0..fb6f7485 100644 --- a/autoload/ctrlp.vim +++ b/autoload/ctrlp.vim @@ -1628,25 +1628,47 @@ fu! s:highlight(pat, grp) el let pat = a:pat - " calculate how many letters are here - let lettercount = len(split(pat, '\\{-}')) - for i in range(lettercount) - " surround the letter we care about with \zs and \ze so only it is - " highlighted in this go. Prefer the letter right next to the previous - " one, otherwise scan out to the last one - let letterpat = substitute(pat, - \ '^\%(\\\?.\zs\[\^\\\?.\]\\{-}\)\{'.i.'}\(\\\?.\)\%(\[\^\\\?.\]\\{-}\)\?\ze.*$', - \ '\\(\\zs\1\\|.*\\zs\1\\)\\ze.\\{-}', '') - - if s:byfname - " replace [^x] with [^/x] to make sure no slashes between letters - let letterpat = substitute(letterpat, '\[\^\(.\{-}\)\]\\{-}', '[^\\/\1]\\{-}', 'g') - " replace the end to make sure no slashes follow the pattern - let letterpat = substitute(letterpat, '\$\@') From e30f152484c11d127934f326d02bfb17c6a2c170 Mon Sep 17 00:00:00 2001 From: Chris Corbyn Date: Sun, 10 Aug 2014 06:54:41 +1000 Subject: [PATCH 23/67] Update .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 06fcd832..3dc7cfe1 100644 --- a/.gitignore +++ b/.gitignore @@ -2,5 +2,6 @@ *.zip note.txt tags +tags-cn .hg* tmp/* From a172b202532958499e96e7b21f7046bacdfb97a5 Mon Sep 17 00:00:00 2001 From: mattn Date: Wed, 27 Nov 2013 11:00:41 +0900 Subject: [PATCH 24/67] Hide cursor shape --- autoload/ctrlp.vim | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/autoload/ctrlp.vim b/autoload/ctrlp.vim index 389191ae..1e31ca5e 100644 --- a/autoload/ctrlp.vim +++ b/autoload/ctrlp.vim @@ -885,17 +885,23 @@ fu! s:MapSpecs() 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), ':\zs.\+\ze$') - exe ( cmd != '' ? cmd : 'norm '.chr ) - en - endw + let t_ve = &t_ve + set t_ve= + try + 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), ':\zs.\+\ze$') + exe ( cmd != '' ? cmd : 'norm '.chr ) + en + endw + fina + let &t_ve = t_ve + endt endf " * Toggling {{{1 fu! s:ToggleFocus() From 3be8ed2f977209a96c22c98f4ea741ef7aa98e22 Mon Sep 17 00:00:00 2001 From: codepiano Date: Mon, 11 Aug 2014 23:12:39 +0800 Subject: [PATCH 25/67] translate recent doc content changes --- doc/ctrlp.cnx | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/doc/ctrlp.cnx b/doc/ctrlp.cnx index d1b3a2fb..ad1d15d1 100644 --- a/doc/ctrlp.cnx +++ b/doc/ctrlp.cnx @@ -186,12 +186,10 @@ OPTIONS *ctrlp-options* let g:ctrlp_working_path_mode = 'ra' < c - 当前文件所在的目录。 - a - 类似 "c", 但是只有在CtrlP之外的当前工作目录不是当前文件所在目录的直接祖 - 先时才生效。(译注:请参考https://github.com/kien/ctrlp.vim/issues/397) - r - 包含下列文件或者目录的最近的祖先: + a - 当前文件所在的目录,除非这个目录为当前工作目录的子目录 + r - 包含下列文件或者目录的最近的祖先目录: .git .hg .svn .bzr _darcs - w - 开始从CtrlP的工作目录之外的目录,而不是当前文件所在的目录(默认)查找根 - 目录。只有在"r"选项存在的时候才生效。 + w - 用来修饰r:使用当前工作目录而不是当前文件所在目录进行查找 0 或者 - 禁用这项功能。 注意 #1: 如果 "a" 或者 "c" 和 "r"一起被包含,当无法找到根目录时使用 "a" 或者 @@ -261,6 +259,9 @@ OPTIONS *ctrlp-options* let g:ctrlp_custom_ignore = { \ 'file': '\v(\.cpp|\.h|\.hh|\.cxx)@ let g:ctrlp_max_files = 10000 From ef4bd78e26197164f8f79d651660c18a2462a712 Mon Sep 17 00:00:00 2001 From: mattn Date: Wed, 24 Sep 2014 09:13:45 +0900 Subject: [PATCH 26/67] Add customizable value. ex: let g:ctrlp_path_nolim = 1 --- autoload/ctrlp.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autoload/ctrlp.vim b/autoload/ctrlp.vim index 1e31ca5e..c141f2f7 100644 --- a/autoload/ctrlp.vim +++ b/autoload/ctrlp.vim @@ -2248,7 +2248,7 @@ fu! s:getextvar(key) let vars = g:ctrlp_ext_vars[s:itemtype - 3] retu has_key(vars, a:key) ? vars[a:key] : -1 en - retu -1 ++ retu get(g:, 'ctrlp_' . s:matchtype . '_' . a:key, -1) endf fu! ctrlp#getcline() From 16b8cd86727140354e9203fc736d51c6f4941c70 Mon Sep 17 00:00:00 2001 From: mattn Date: Wed, 24 Sep 2014 09:18:14 +0900 Subject: [PATCH 27/67] Add doc --- doc/ctrlp.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/doc/ctrlp.txt b/doc/ctrlp.txt index 20f2ffe3..4ed78ae8 100644 --- a/doc/ctrlp.txt +++ b/doc/ctrlp.txt @@ -773,6 +773,12 @@ Example: > " } endfunction < + *ctrlp-default-value* +Otherwize, you can use below to change default value. +Example: > + let g:ctrlp_path_nolim = 1 + +This is possible to change no-limit mode for match type "path". =============================================================================== COMMANDS *ctrlp-commands* From a651eacf4bf5041a5313952f288a7620571809d2 Mon Sep 17 00:00:00 2001 From: mattn Date: Tue, 30 Sep 2014 22:13:51 +0900 Subject: [PATCH 28/67] Remove needless + --- autoload/ctrlp.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autoload/ctrlp.vim b/autoload/ctrlp.vim index c141f2f7..f82ea81c 100644 --- a/autoload/ctrlp.vim +++ b/autoload/ctrlp.vim @@ -2248,7 +2248,7 @@ fu! s:getextvar(key) let vars = g:ctrlp_ext_vars[s:itemtype - 3] retu has_key(vars, a:key) ? vars[a:key] : -1 en -+ retu get(g:, 'ctrlp_' . s:matchtype . '_' . a:key, -1) + retu get(g:, 'ctrlp_' . s:matchtype . '_' . a:key, -1) endf fu! ctrlp#getcline() From e2a7cf76c48c587076426dccdc7b2d22a64f355a Mon Sep 17 00:00:00 2001 From: mattn Date: Thu, 9 Oct 2014 09:22:12 +0900 Subject: [PATCH 29/67] Add bang flag for CtrlPBookmarkDirAdd to avoid ask some. Close #35 --- autoload/ctrlp/bookmarkdir.vim | 19 ++++++++++++------- plugin/ctrlp.vim | 4 ++-- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/autoload/ctrlp/bookmarkdir.vim b/autoload/ctrlp/bookmarkdir.vim index 89bda895..928d07f2 100644 --- a/autoload/ctrlp/bookmarkdir.vim +++ b/autoload/ctrlp/bookmarkdir.vim @@ -112,13 +112,18 @@ fu! ctrlp#bookmarkdir#accept(mode, str) en endf -fu! ctrlp#bookmarkdir#add(dir, ...) - let str = 'Directory to bookmark: ' - let cwd = a:dir != '' ? a:dir : s:getinput(str, getcwd(), 'dir') - if cwd == '' | retu | en - let cwd = fnamemodify(cwd, ':p') - let name = a:0 && a:1 != '' ? a:1 : s:getinput('Bookmark as: ', cwd) - if name == '' | retu | en +fu! ctrlp#bookmarkdir#add(bang, dir, ...) + if a:bang == '!' + let cwd = fnamemodify(a:dir != '' ? a:dir : getcwd(), 'p') + let name = a:0 && a:1 != '' ? a:1 : cwd + el + let str = 'Directory to bookmark: ' + let cwd = a:dir != '' ? a:dir : s:getinput(str, getcwd(), 'dir') + if cwd == '' | retu | en + let cwd = fnamemodify(cwd, ':p') + let name = a:0 && a:1 != '' ? a:1 : s:getinput('Bookmark as: ', cwd) + if name == '' | retu | en + en let name = tr(name, ' ', ' ') cal s:savebookmark(name, cwd) cal s:msg(name, cwd) diff --git a/plugin/ctrlp.vim b/plugin/ctrlp.vim index c7b8fa3f..6b3e2346 100644 --- a/plugin/ctrlp.vim +++ b/plugin/ctrlp.vim @@ -62,7 +62,7 @@ com! -bar CtrlPChangeAll cal ctrlp#init(ctrlp#changes#cmd(1)) com! -bar CtrlPMixed cal ctrlp#init(ctrlp#mixed#id()) com! -bar CtrlPBookmarkDir cal ctrlp#init(ctrlp#bookmarkdir#id()) -com! -n=? -com=dir CtrlPBookmarkDirAdd - \ cal ctrlp#call('ctrlp#bookmarkdir#add', ) +com! -n=? -com=dir -bang CtrlPBookmarkDirAdd + \ cal ctrlp#call('ctrlp#bookmarkdir#add', '', ) " vim:ts=2:sw=2:sts=2 From 4eadf37fe84e503af0ab14b6c8d7c254044102dc Mon Sep 17 00:00:00 2001 From: Sergey Vlasov Date: Fri, 7 Nov 2014 17:52:40 +0200 Subject: [PATCH 30/67] New buffer explorer mode with highlighting --- autoload/ctrlp.vim | 147 +++++++++++++++++++++++++++++++-------------- doc/ctrlp.txt | 22 ++++++- 2 files changed, 121 insertions(+), 48 deletions(-) diff --git a/autoload/ctrlp.vim b/autoload/ctrlp.vim index f82ea81c..f1fe024d 100644 --- a/autoload/ctrlp.vim +++ b/autoload/ctrlp.vim @@ -160,6 +160,8 @@ let s:fpats = { \ '^\S\*$': '\*', \ '^\S\\?$': '\\?', \ } +let s:bufnrpat = '\s[{]*\zs\d\+' +let s:bufindpat = '\[\zs[#+]*\ze\]' " Keypad let s:kprange = { @@ -180,6 +182,15 @@ let s:hlgrps = { \ 'PrtBase': 'Comment', \ 'PrtText': 'Normal', \ 'PrtCursor': 'Constant', + \ 'BufferNr': 'Constant', + \ 'BufferInd': 'Normal', + \ 'BufferHid': 'Comment', + \ 'BufferHidMod': 'String', + \ 'BufferVis': 'Normal', + \ 'BufferVisMod': 'Identifier', + \ 'BufferCur': 'Question', + \ 'BufferCurMod': 'WarningMsg', + \ 'BufferPath': 'Comment', \ } " Get the options {{{2 fu! s:opts(...) @@ -442,18 +453,34 @@ endf fu! ctrlp#buffers(...) let ids = sort(filter(range(1, bufnr('$')), 'empty(getbufvar(v:val, "&bt"))' \ .' && getbufvar(v:val, "&bl")'), 's:compmreb') - if a:0 && a:1 == 'id' - retu ids - el - let bufs = [[], []] - for id in ids - let bname = bufname(id) - let ebname = bname == '' - let fname = fnamemodify(ebname ? '['.id.'*No Name]' : bname, ':.') - cal add(bufs[ebname], fname) - endfo - retu bufs[0] + bufs[1] - en + let lines = [] + for id in ids + let bname = bufname(id) + let bname = (bname == '' ? '[No Name]' : bname) + let flag = + \ (bufwinnr(id) != -1 ? '*' : '') . + \ (getbufvar(id, '&mod') ? '+' : '') . + \ (id == s:crbufnr ? '!' : '') + let indicator = + \ (id == bufnr('#') ? '#' : '') . + \ (getbufvar(id, '&mod') ? '+' : '') + + if has('conceal') + let line = printf('%5s %-4s %s%-32s %s', + \ '{'.id.'}', + \ '['.indicator.']', + \ '('.flag, '{'.fnamemodify(bname, ':t').'})', + \ '<'.fnamemodify(bname, ':~:.:h').s:lash().'>') + el + let line = printf('%3s %-2s %-30s %s', + \ id, + \ indicator, + \ fnamemodify(bname, ':t'), + \ fnamemodify(bname, ':~:.:h').'/') + en + cal add(lines, line) + endfo + retu lines endf " * MatchedItems() {{{1 fu! s:MatchIt(items, pat, limit, exc) @@ -473,7 +500,7 @@ fu! s:MatchIt(items, pat, limit, exc) endf fu! s:MatchedItems(items, pat, limit) - let exc = exists('s:crfilerel') ? s:crfilerel : '' + let exc = s:itemtype == 1 ? '' : exists('s:crfilerel') ? s:crfilerel : '' let items = s:narrowable() ? s:matched + s:mdata[3] : a:items if s:matcher != {} let argms = @@ -812,7 +839,9 @@ fu! s:PrtClearCache() endf fu! s:PrtDeleteEnt() - if s:itemtype == 2 + if s:itemtype == 1 + cal s:delbuf() + elsei s:itemtype == 2 cal s:PrtDeleteMRU() elsei type(s:getextvar('wipe')) == 1 cal s:delent(s:getextvar('wipe')) @@ -986,16 +1015,13 @@ fu! ctrlp#acceptfile(...) let [md, line] = [a:1, a:2] let atl = a:0 > 2 ? a:3 : '' en - if !type(line) - let [filpath, bufnr, useb] = [line, line, 1] + if s:itemtype == 1 + let useb = 1 + let bufnr = str2nr(matchstr(line, s:bufnrpat)) + let filpath = fnamemodify(bufname(bufnr), ':p') el let filpath = fnamemodify(line, ':p') - if s:nonamecond(line, filpath) - let bufnr = str2nr(matchstr(line, '[\/]\?\[\zs\d\+\ze\*No Name\]$')) - let [filpath, useb] = [bufnr, 1] - el - let bufnr = bufnr('^'.filpath.'$') - en + let bufnr = bufnr('^'.filpath.'$') en cal s:PrtExit() let tail = s:tail() @@ -1330,7 +1356,7 @@ endf fu! s:mixedsort(...) if s:itemtype == 1 - let pat = '[\/]\?\[\d\+\*No Name\]$' + let pat = '\[No Name\]' if a:1 =~# pat && a:2 =~# pat | retu 0 elsei a:1 =~# pat | retu 1 elsei a:2 =~# pat | retu -1 | en @@ -1431,18 +1457,7 @@ endf " Line formatting {{{3 fu! s:formatline(str) let str = a:str - if s:itemtype == 1 - let filpath = fnamemodify(str, ':p') - let bufnr = s:nonamecond(str, filpath) - \ ? str2nr(matchstr(str, '[\/]\?\[\zs\d\+\ze\*No Name\]$')) - \ : bufnr('^'.filpath.'$') - let idc = ( bufnr == bufnr('#') ? '#' : '' ) - \ . ( getbufvar(bufnr, '&ma') ? '' : '-' ) - \ . ( getbufvar(bufnr, '&ro') ? '=' : '' ) - \ . ( getbufvar(bufnr, '&mod') ? '+' : '' ) - let str .= idc != '' ? ' '.idc : '' - en - let cond = s:ispath && ( s:winw - 4 ) < s:strwidth(str) + let cond = s:ispath && s:itemtype != 1 && ( s:winw - 4 ) < s:strwidth(str) retu '> '.( cond ? s:pathshorten(str) : str ) endf @@ -1644,6 +1659,20 @@ fu! ctrlp#syntax() if hlexists('CtrlPLinePre') sy match CtrlPLinePre '^>' en + + if has('conceal') + sy region CtrlPBufferNr concealends matchgroup=Ignore start='{' end='}' + sy region CtrlPBufferInd concealends matchgroup=Ignore start='\[' end='\]' + sy region CtrlPBufferRegion concealends matchgroup=Ignore start='(' end=')' + \ contains=CtrlPBufferHid,CtrlPBufferHidMod,CtrlPBufferVis,CtrlPBufferVisMod,CtrlPBufferCur,CtrlPBufferCurMod + sy region CtrlPBufferHid concealends matchgroup=Ignore start='\s*{' end='}' contained + sy region CtrlPBufferHidMod concealends matchgroup=Ignore start='+\s*{' end='}' contained + sy region CtrlPBufferVis concealends matchgroup=Ignore start='\*\s*{' end='}' contained + sy region CtrlPBufferVisMod concealends matchgroup=Ignore start='\*+\s*{' end='}' contained + sy region CtrlPBufferCur concealends matchgroup=Ignore start='\*!\s*{' end='}' contained + sy region CtrlPBufferCurMod concealends matchgroup=Ignore start='\*+!\s*{' end='}' contained + sy region CtrlPBufferPath concealends matchgroup=Ignore start='<' end='>' + en endf fu! s:highlight(pat, grp) @@ -1666,7 +1695,7 @@ fu! s:highlight(pat, grp) let ending = '\(.*'.pat.'\)\@!' " Case sensitive? let beginning = ( s:martcs == '' ? '\c' : '\C' ).'^.*' - if s:byfname + if s:byfname && s:itemtype != 1 " Make sure there are no slashes in our match let beginning = beginning.'\([^\/]*$\)\@=' end @@ -1806,11 +1835,6 @@ fu! s:bufwins(bufnr) retu winns endf -fu! s:nonamecond(str, filpath) - retu a:str =~ '[\/]\?\[\d\+\*No Name\]$' && !filereadable(a:filpath) - \ && bufnr('^'.a:filpath.'$') < 1 -endf - fu! ctrlp#normcmd(cmd, ...) if a:0 < 2 && s:nosplit() | retu a:cmd | en let norwins = filter(range(1, winnr('$')), @@ -1846,6 +1870,9 @@ fu! s:setupblank() if v:version > 702 setl nornu noudf cc=0 en + if has('conceal') + setl cole=2 cocu=nc + en endf fu! s:leavepre() @@ -1982,7 +2009,7 @@ fu! s:nosort() endf fu! s:byfname() - retu s:ispath && s:byfname + retu s:itemtype != 1 && s:ispath && s:byfname endf fu! s:narrowable() @@ -2060,6 +2087,25 @@ fu! s:delent(rfunc) cal s:BuildPrompt(1) unl s:force endf + +fu! s:delbuf() + let lines = [] + if exists('s:marked') + let lines = values(s:marked) + for line in lines + let bufnr = matchstr(line, s:bufnrpat) + exe ":bd ". bufnr + endfo + cal s:unmarksigns() + unl s:marked + else + let line = ctrlp#getcline() + let bufnr = matchstr(line, s:bufnrpat) + exe ":bd ". bufnr + en + call s:PrtClearCache() +endf + " Entering & Exiting {{{2 fu! s:getenv() let [s:cwd, s:winres] = [getcwd(), [winrestcmd(), &lines, winnr('$')]] @@ -2067,8 +2113,7 @@ fu! s:getenv() let [s:crgfile, s:crline] = [expand('', 1), getline('.')] let [s:winmaxh, s:crcursor] = [min([s:mw_max, &lines]), getpos('.')] let [s:crbufnr, s:crvisual] = [bufnr('%'), s:lastvisual()] - let s:crfile = bufname('%') == '' - \ ? '['.s:crbufnr.'*No Name]' : expand('%:p', 1) + let s:crfile = bufname('%') == '' ? '[No Name]' : expand('%:p', 1) let s:crfpath = expand('%:p:h', 1) let s:mrbs = ctrlp#mrufiles#bufs() endf @@ -2155,6 +2200,15 @@ fu! s:matchfname(item, pat) en endf +fu! s:matchbuf(item, pat) + let bufnr = str2nr(matchstr(a:item, s:bufnrpat)) + let bufind = matchstr(a:item, s:bufindpat) + let bname = fnamemodify(bufname(bufnr), ':t') + let bpath = fnamemodify(bufname(bufnr), ':~:.:h') + let item = bufnr.bufind.bname.s:lash().bpath + retu match(item, a:pat) +endf + fu! s:matchtabs(item, pat) retu match(split(a:item, '\t\+')[0], a:pat) endf @@ -2173,7 +2227,9 @@ endf fu! s:mfunc() let mfunc = 'match' - if s:byfname() + if s:itemtype == 1 + let mfunc = 's:matchbuf' + elsei s:byfname() let mfunc = 's:matchfname' elsei s:itemtype > 2 let matchtypes = { 'tabs': 's:matchtabs', 'tabe': 's:matchtabe' } @@ -2188,6 +2244,7 @@ fu! s:mmode() let matchmodes = { \ 'match': 'full-line', \ 's:matchfname': 'filename-only', + \ 's:matchbuf': 'full-line', \ 's:matchtabs': 'first-non-tab', \ 's:matchtabe': 'until-last-tab', \ } diff --git a/doc/ctrlp.txt b/doc/ctrlp.txt index 4ed78ae8..ec9273aa 100644 --- a/doc/ctrlp.txt +++ b/doc/ctrlp.txt @@ -960,8 +960,12 @@ Function keys:~ - Remove deleted files from the MRU list. - - Wipe the MRU list. - - Delete MRU entries marked by . + MRU mode: + - Wipe the list. + - Delete entries marked by . + Buffer mode: + - Delete entry under the cursor or delete multiple entries marked by . + Pasting:~ @@ -1196,6 +1200,17 @@ Highlighting:~ CtrlPPrtText : the prompt's text (|hl-Normal|) CtrlPPrtCursor : the prompt's cursor when moving over the text (Constant) + * Buffer explorer mode: + CtrlPBufferNr : buffer number + CtrlPBufferInd : '+' and '#' indicators (see |:buffers|) + CtrlPBufferHid : hidden buffer + CtrlPBufferHidMod : hidden and modified buffer + CtrlPBufferVis : visible buffer + CtrlPBufferVisMod : visible and modified buffer + CtrlPBufferCur : current buffer + CtrlPBufferCurMod : current and modified buffer + CtrlPBufferPath : buffer path + * In extensions: CtrlPTabExtra : the part of each line that's not matched against (Comment) CtrlPBufName : the buffer name an entry belongs to (|hl-Directory|) @@ -1297,10 +1312,11 @@ Special thanks:~ * Jo De Boeck * Rudi Grinberg * Timothy Mellor + * Sergey Vlasov =============================================================================== CHANGELOG *ctrlp-changelog* - + + New buffer explorer mode with highlighting (|+conceal| recommended) + Combine *g:ctrlp_match_window_bottom* *g:ctrlp_match_window_reversed* and *g:ctrlp_max_height* into |g:ctrlp_match_window|. + New option: |g:ctrlp_match_window|. From 1ad49d40f1438913f6631ea5078b9519050a01ef Mon Sep 17 00:00:00 2001 From: mattn Date: Sat, 15 Nov 2014 09:20:51 +0900 Subject: [PATCH 31/67] Revert "New buffer explorer mode with highlighting and more" --- autoload/ctrlp.vim | 147 ++++++++++++++------------------------------- doc/ctrlp.txt | 22 +------ 2 files changed, 48 insertions(+), 121 deletions(-) diff --git a/autoload/ctrlp.vim b/autoload/ctrlp.vim index f1fe024d..f82ea81c 100644 --- a/autoload/ctrlp.vim +++ b/autoload/ctrlp.vim @@ -160,8 +160,6 @@ let s:fpats = { \ '^\S\*$': '\*', \ '^\S\\?$': '\\?', \ } -let s:bufnrpat = '\s[{]*\zs\d\+' -let s:bufindpat = '\[\zs[#+]*\ze\]' " Keypad let s:kprange = { @@ -182,15 +180,6 @@ let s:hlgrps = { \ 'PrtBase': 'Comment', \ 'PrtText': 'Normal', \ 'PrtCursor': 'Constant', - \ 'BufferNr': 'Constant', - \ 'BufferInd': 'Normal', - \ 'BufferHid': 'Comment', - \ 'BufferHidMod': 'String', - \ 'BufferVis': 'Normal', - \ 'BufferVisMod': 'Identifier', - \ 'BufferCur': 'Question', - \ 'BufferCurMod': 'WarningMsg', - \ 'BufferPath': 'Comment', \ } " Get the options {{{2 fu! s:opts(...) @@ -453,34 +442,18 @@ endf fu! ctrlp#buffers(...) let ids = sort(filter(range(1, bufnr('$')), 'empty(getbufvar(v:val, "&bt"))' \ .' && getbufvar(v:val, "&bl")'), 's:compmreb') - let lines = [] - for id in ids - let bname = bufname(id) - let bname = (bname == '' ? '[No Name]' : bname) - let flag = - \ (bufwinnr(id) != -1 ? '*' : '') . - \ (getbufvar(id, '&mod') ? '+' : '') . - \ (id == s:crbufnr ? '!' : '') - let indicator = - \ (id == bufnr('#') ? '#' : '') . - \ (getbufvar(id, '&mod') ? '+' : '') - - if has('conceal') - let line = printf('%5s %-4s %s%-32s %s', - \ '{'.id.'}', - \ '['.indicator.']', - \ '('.flag, '{'.fnamemodify(bname, ':t').'})', - \ '<'.fnamemodify(bname, ':~:.:h').s:lash().'>') - el - let line = printf('%3s %-2s %-30s %s', - \ id, - \ indicator, - \ fnamemodify(bname, ':t'), - \ fnamemodify(bname, ':~:.:h').'/') - en - cal add(lines, line) - endfo - retu lines + if a:0 && a:1 == 'id' + retu ids + el + let bufs = [[], []] + for id in ids + let bname = bufname(id) + let ebname = bname == '' + let fname = fnamemodify(ebname ? '['.id.'*No Name]' : bname, ':.') + cal add(bufs[ebname], fname) + endfo + retu bufs[0] + bufs[1] + en endf " * MatchedItems() {{{1 fu! s:MatchIt(items, pat, limit, exc) @@ -500,7 +473,7 @@ fu! s:MatchIt(items, pat, limit, exc) endf fu! s:MatchedItems(items, pat, limit) - let exc = s:itemtype == 1 ? '' : exists('s:crfilerel') ? s:crfilerel : '' + let exc = exists('s:crfilerel') ? s:crfilerel : '' let items = s:narrowable() ? s:matched + s:mdata[3] : a:items if s:matcher != {} let argms = @@ -839,9 +812,7 @@ fu! s:PrtClearCache() endf fu! s:PrtDeleteEnt() - if s:itemtype == 1 - cal s:delbuf() - elsei s:itemtype == 2 + if s:itemtype == 2 cal s:PrtDeleteMRU() elsei type(s:getextvar('wipe')) == 1 cal s:delent(s:getextvar('wipe')) @@ -1015,13 +986,16 @@ fu! ctrlp#acceptfile(...) let [md, line] = [a:1, a:2] let atl = a:0 > 2 ? a:3 : '' en - if s:itemtype == 1 - let useb = 1 - let bufnr = str2nr(matchstr(line, s:bufnrpat)) - let filpath = fnamemodify(bufname(bufnr), ':p') + if !type(line) + let [filpath, bufnr, useb] = [line, line, 1] el let filpath = fnamemodify(line, ':p') - let bufnr = bufnr('^'.filpath.'$') + if s:nonamecond(line, filpath) + let bufnr = str2nr(matchstr(line, '[\/]\?\[\zs\d\+\ze\*No Name\]$')) + let [filpath, useb] = [bufnr, 1] + el + let bufnr = bufnr('^'.filpath.'$') + en en cal s:PrtExit() let tail = s:tail() @@ -1356,7 +1330,7 @@ endf fu! s:mixedsort(...) if s:itemtype == 1 - let pat = '\[No Name\]' + let pat = '[\/]\?\[\d\+\*No Name\]$' if a:1 =~# pat && a:2 =~# pat | retu 0 elsei a:1 =~# pat | retu 1 elsei a:2 =~# pat | retu -1 | en @@ -1457,7 +1431,18 @@ endf " Line formatting {{{3 fu! s:formatline(str) let str = a:str - let cond = s:ispath && s:itemtype != 1 && ( s:winw - 4 ) < s:strwidth(str) + if s:itemtype == 1 + let filpath = fnamemodify(str, ':p') + let bufnr = s:nonamecond(str, filpath) + \ ? str2nr(matchstr(str, '[\/]\?\[\zs\d\+\ze\*No Name\]$')) + \ : bufnr('^'.filpath.'$') + let idc = ( bufnr == bufnr('#') ? '#' : '' ) + \ . ( getbufvar(bufnr, '&ma') ? '' : '-' ) + \ . ( getbufvar(bufnr, '&ro') ? '=' : '' ) + \ . ( getbufvar(bufnr, '&mod') ? '+' : '' ) + let str .= idc != '' ? ' '.idc : '' + en + let cond = s:ispath && ( s:winw - 4 ) < s:strwidth(str) retu '> '.( cond ? s:pathshorten(str) : str ) endf @@ -1659,20 +1644,6 @@ fu! ctrlp#syntax() if hlexists('CtrlPLinePre') sy match CtrlPLinePre '^>' en - - if has('conceal') - sy region CtrlPBufferNr concealends matchgroup=Ignore start='{' end='}' - sy region CtrlPBufferInd concealends matchgroup=Ignore start='\[' end='\]' - sy region CtrlPBufferRegion concealends matchgroup=Ignore start='(' end=')' - \ contains=CtrlPBufferHid,CtrlPBufferHidMod,CtrlPBufferVis,CtrlPBufferVisMod,CtrlPBufferCur,CtrlPBufferCurMod - sy region CtrlPBufferHid concealends matchgroup=Ignore start='\s*{' end='}' contained - sy region CtrlPBufferHidMod concealends matchgroup=Ignore start='+\s*{' end='}' contained - sy region CtrlPBufferVis concealends matchgroup=Ignore start='\*\s*{' end='}' contained - sy region CtrlPBufferVisMod concealends matchgroup=Ignore start='\*+\s*{' end='}' contained - sy region CtrlPBufferCur concealends matchgroup=Ignore start='\*!\s*{' end='}' contained - sy region CtrlPBufferCurMod concealends matchgroup=Ignore start='\*+!\s*{' end='}' contained - sy region CtrlPBufferPath concealends matchgroup=Ignore start='<' end='>' - en endf fu! s:highlight(pat, grp) @@ -1695,7 +1666,7 @@ fu! s:highlight(pat, grp) let ending = '\(.*'.pat.'\)\@!' " Case sensitive? let beginning = ( s:martcs == '' ? '\c' : '\C' ).'^.*' - if s:byfname && s:itemtype != 1 + if s:byfname " Make sure there are no slashes in our match let beginning = beginning.'\([^\/]*$\)\@=' end @@ -1835,6 +1806,11 @@ fu! s:bufwins(bufnr) retu winns endf +fu! s:nonamecond(str, filpath) + retu a:str =~ '[\/]\?\[\d\+\*No Name\]$' && !filereadable(a:filpath) + \ && bufnr('^'.a:filpath.'$') < 1 +endf + fu! ctrlp#normcmd(cmd, ...) if a:0 < 2 && s:nosplit() | retu a:cmd | en let norwins = filter(range(1, winnr('$')), @@ -1870,9 +1846,6 @@ fu! s:setupblank() if v:version > 702 setl nornu noudf cc=0 en - if has('conceal') - setl cole=2 cocu=nc - en endf fu! s:leavepre() @@ -2009,7 +1982,7 @@ fu! s:nosort() endf fu! s:byfname() - retu s:itemtype != 1 && s:ispath && s:byfname + retu s:ispath && s:byfname endf fu! s:narrowable() @@ -2087,25 +2060,6 @@ fu! s:delent(rfunc) cal s:BuildPrompt(1) unl s:force endf - -fu! s:delbuf() - let lines = [] - if exists('s:marked') - let lines = values(s:marked) - for line in lines - let bufnr = matchstr(line, s:bufnrpat) - exe ":bd ". bufnr - endfo - cal s:unmarksigns() - unl s:marked - else - let line = ctrlp#getcline() - let bufnr = matchstr(line, s:bufnrpat) - exe ":bd ". bufnr - en - call s:PrtClearCache() -endf - " Entering & Exiting {{{2 fu! s:getenv() let [s:cwd, s:winres] = [getcwd(), [winrestcmd(), &lines, winnr('$')]] @@ -2113,7 +2067,8 @@ fu! s:getenv() let [s:crgfile, s:crline] = [expand('', 1), getline('.')] let [s:winmaxh, s:crcursor] = [min([s:mw_max, &lines]), getpos('.')] let [s:crbufnr, s:crvisual] = [bufnr('%'), s:lastvisual()] - let s:crfile = bufname('%') == '' ? '[No Name]' : expand('%:p', 1) + let s:crfile = bufname('%') == '' + \ ? '['.s:crbufnr.'*No Name]' : expand('%:p', 1) let s:crfpath = expand('%:p:h', 1) let s:mrbs = ctrlp#mrufiles#bufs() endf @@ -2200,15 +2155,6 @@ fu! s:matchfname(item, pat) en endf -fu! s:matchbuf(item, pat) - let bufnr = str2nr(matchstr(a:item, s:bufnrpat)) - let bufind = matchstr(a:item, s:bufindpat) - let bname = fnamemodify(bufname(bufnr), ':t') - let bpath = fnamemodify(bufname(bufnr), ':~:.:h') - let item = bufnr.bufind.bname.s:lash().bpath - retu match(item, a:pat) -endf - fu! s:matchtabs(item, pat) retu match(split(a:item, '\t\+')[0], a:pat) endf @@ -2227,9 +2173,7 @@ endf fu! s:mfunc() let mfunc = 'match' - if s:itemtype == 1 - let mfunc = 's:matchbuf' - elsei s:byfname() + if s:byfname() let mfunc = 's:matchfname' elsei s:itemtype > 2 let matchtypes = { 'tabs': 's:matchtabs', 'tabe': 's:matchtabe' } @@ -2244,7 +2188,6 @@ fu! s:mmode() let matchmodes = { \ 'match': 'full-line', \ 's:matchfname': 'filename-only', - \ 's:matchbuf': 'full-line', \ 's:matchtabs': 'first-non-tab', \ 's:matchtabe': 'until-last-tab', \ } diff --git a/doc/ctrlp.txt b/doc/ctrlp.txt index ec9273aa..4ed78ae8 100644 --- a/doc/ctrlp.txt +++ b/doc/ctrlp.txt @@ -960,12 +960,8 @@ Function keys:~ - Remove deleted files from the MRU list. - MRU mode: - - Wipe the list. - - Delete entries marked by . - Buffer mode: - - Delete entry under the cursor or delete multiple entries marked by . - + - Wipe the MRU list. + - Delete MRU entries marked by . Pasting:~ @@ -1200,17 +1196,6 @@ Highlighting:~ CtrlPPrtText : the prompt's text (|hl-Normal|) CtrlPPrtCursor : the prompt's cursor when moving over the text (Constant) - * Buffer explorer mode: - CtrlPBufferNr : buffer number - CtrlPBufferInd : '+' and '#' indicators (see |:buffers|) - CtrlPBufferHid : hidden buffer - CtrlPBufferHidMod : hidden and modified buffer - CtrlPBufferVis : visible buffer - CtrlPBufferVisMod : visible and modified buffer - CtrlPBufferCur : current buffer - CtrlPBufferCurMod : current and modified buffer - CtrlPBufferPath : buffer path - * In extensions: CtrlPTabExtra : the part of each line that's not matched against (Comment) CtrlPBufName : the buffer name an entry belongs to (|hl-Directory|) @@ -1312,11 +1297,10 @@ Special thanks:~ * Jo De Boeck * Rudi Grinberg * Timothy Mellor - * Sergey Vlasov =============================================================================== CHANGELOG *ctrlp-changelog* - + New buffer explorer mode with highlighting (|+conceal| recommended) + + Combine *g:ctrlp_match_window_bottom* *g:ctrlp_match_window_reversed* and *g:ctrlp_max_height* into |g:ctrlp_match_window|. + New option: |g:ctrlp_match_window|. From 23ef81965864baf976d45b57a928a3810bff097f Mon Sep 17 00:00:00 2001 From: John Szakmeister Date: Sat, 15 Nov 2014 06:49:45 -0500 Subject: [PATCH 32/67] Center the screen on the tag after jumping. This also makes the behavior consistent with buffertag, changes, and quickfix. It originally used `sil! norm! zvzz`, just as the others do, but that didn't play well with the use of `feedkeys()` in `ctrlp#tag#accept()`. Instead, we now use `feedkeys()` to do the centering. --- autoload/ctrlp/tag.vim | 1 + 1 file changed, 1 insertion(+) diff --git a/autoload/ctrlp/tag.vim b/autoload/ctrlp/tag.vim index 626363a4..fa8c732f 100644 --- a/autoload/ctrlp/tag.vim +++ b/autoload/ctrlp/tag.vim @@ -121,6 +121,7 @@ fu! ctrlp#tag#accept(mode, str) en cal feedkeys(":".cmd." ".tg."\r".ext, 'nt') en + cal feedkeys('zvzz', 'nt') cal ctrlp#setlcdir() endf From 3e68157e834f5af614521f577db88e43ee8161d2 Mon Sep 17 00:00:00 2001 From: Jit Yap Date: Sun, 16 Nov 2014 03:37:04 +0000 Subject: [PATCH 33/67] Fix for switch_buffer --- autoload/ctrlp.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autoload/ctrlp.vim b/autoload/ctrlp.vim index f82ea81c..fd87297d 100644 --- a/autoload/ctrlp.vim +++ b/autoload/ctrlp.vim @@ -1000,7 +1000,7 @@ fu! ctrlp#acceptfile(...) cal s:PrtExit() let tail = s:tail() let j2l = atl != '' ? atl : matchstr(tail, '^ +\zs\d\+$') - if ( s:jmptobuf =~ md || ( s:jmptobuf && md =~ '[et]' ) ) && bufnr > 0 + if ( s:jmptobuf =~ md || ( strlen(s:jmptobuf) && s:jmptobuf !~# '\v^0$' && md =~ '[et]' ) ) && bufnr > 0 \ && !( md == 'e' && bufnr == bufnr('%') ) let [jmpb, bufwinnr] = [1, bufwinnr(bufnr)] let buftab = ( s:jmptobuf =~# '[tTVH]' || s:jmptobuf > 1 ) From bba96f92f8b5915bac511d5b269e39bd9db85efd Mon Sep 17 00:00:00 2001 From: gelguy Date: Sun, 16 Nov 2014 15:37:42 +0000 Subject: [PATCH 34/67] Used !empty(s:jmptobuf) --- autoload/ctrlp.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autoload/ctrlp.vim b/autoload/ctrlp.vim index fd87297d..3538c05e 100644 --- a/autoload/ctrlp.vim +++ b/autoload/ctrlp.vim @@ -1000,7 +1000,7 @@ fu! ctrlp#acceptfile(...) cal s:PrtExit() let tail = s:tail() let j2l = atl != '' ? atl : matchstr(tail, '^ +\zs\d\+$') - if ( s:jmptobuf =~ md || ( strlen(s:jmptobuf) && s:jmptobuf !~# '\v^0$' && md =~ '[et]' ) ) && bufnr > 0 + if ( s:jmptobuf =~ md || ( !empty(s:jmptobuf) && s:jmptobuf !~# '\v^0$' && md =~ '[et]' ) ) && bufnr > 0 \ && !( md == 'e' && bufnr == bufnr('%') ) let [jmpb, bufwinnr] = [1, bufwinnr(bufnr)] let buftab = ( s:jmptobuf =~# '[tTVH]' || s:jmptobuf > 1 ) From d9b6499fd38ba8672613e2e77cd9e62b3a89f9e2 Mon Sep 17 00:00:00 2001 From: mattn Date: Mon, 17 Nov 2014 09:19:36 +0900 Subject: [PATCH 35/67] Fix #56 --- autoload/ctrlp.vim | 1 - 1 file changed, 1 deletion(-) diff --git a/autoload/ctrlp.vim b/autoload/ctrlp.vim index f82ea81c..8976dec8 100644 --- a/autoload/ctrlp.vim +++ b/autoload/ctrlp.vim @@ -2152,7 +2152,6 @@ fu! s:matchfname(item, pat) retu len(a:pat) == 1 ? mfn : len(a:pat) == 2 ? \ ( mfn >= 0 && ( len(parts) == 2 ? match(parts[0], a:pat[1]) : -1 ) >= 0 \ ? 0 : -1 ) : -1 - en endf fu! s:matchtabs(item, pat) From 237d276a85eeaabc58aa1ac6de5af8ab079f606e Mon Sep 17 00:00:00 2001 From: codepiano Date: Sat, 22 Nov 2014 19:01:17 +0800 Subject: [PATCH 36/67] translate recent doc changes --- doc/ctrlp.cnx | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/doc/ctrlp.cnx b/doc/ctrlp.cnx index ad1d15d1..66266675 100644 --- a/doc/ctrlp.cnx +++ b/doc/ctrlp.cnx @@ -742,7 +742,12 @@ MRU mode options:~ " } endfunction < + *ctrl默认值* +另外,你可以使用下面的方式来改变默认值。 +例子: > + let g:ctrlp_path_nolim = 1 +这样可以让无限制模式匹配“路径”类型。 =============================================================================== 命令 *ctrlp-commands* From bb4ad49185c2f3e5033e2cd5044c8826b9c87611 Mon Sep 17 00:00:00 2001 From: Jan Larres Date: Wed, 26 Nov 2014 11:21:15 +1300 Subject: [PATCH 37/67] Use empty "extra" option for ctags If a user has added "--extra=+q" in their ~/.ctags to include qualified tags then ctrlp will list all tags twice, once in a qualified and once in a base form. Force an empty "extra" option to prevent this. --- autoload/ctrlp/buffertag.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autoload/ctrlp/buffertag.vim b/autoload/ctrlp/buffertag.vim index a38cad56..83a0c5c3 100644 --- a/autoload/ctrlp/buffertag.vim +++ b/autoload/ctrlp/buffertag.vim @@ -130,7 +130,7 @@ fu! s:exectags(cmd) endf fu! s:exectagsonfile(fname, ftype) - let [ags, ft] = ['-f - --sort=no --excmd=pattern --fields=nKs ', a:ftype] + let [ags, ft] = ['-f - --sort=no --excmd=pattern --fields=nKs --extra= ', a:ftype] if type(s:types[ft]) == 1 let ags .= s:types[ft] let bin = s:bin From a35d4000338a9f07ec35ada16c877208baeeb923 Mon Sep 17 00:00:00 2001 From: mattn Date: Tue, 2 Dec 2014 19:35:33 +0900 Subject: [PATCH 38/67] Add (ctrlp) --- plugin/ctrlp.vim | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/plugin/ctrlp.vim b/plugin/ctrlp.vim index 6b3e2346..bf42d49c 100644 --- a/plugin/ctrlp.vim +++ b/plugin/ctrlp.vim @@ -33,8 +33,10 @@ 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': 'r' }) -if g:ctrlp_map != '' && !hasmapto(':'.g:ctrlp_cmd.'', 'n') - exe 'nn ' g:ctrlp_map ':'.g:ctrlp_cmd.'' +exe 'nn (ctrlp) :'.g:ctrlp_cmd.'' + +if g:ctrlp_map != '' && !hasmapto('(ctrlp)') + exe 'map ' g:ctrlp_map '(ctrlp)' en cal ctrlp#mrufiles#init() From db3e8b1af4bc8a4e148dd7ee821a801c6c9a08c1 Mon Sep 17 00:00:00 2001 From: mattn Date: Tue, 2 Dec 2014 19:38:49 +0900 Subject: [PATCH 39/67] Remove needless --- plugin/ctrlp.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/ctrlp.vim b/plugin/ctrlp.vim index bf42d49c..5f5303f1 100644 --- a/plugin/ctrlp.vim +++ b/plugin/ctrlp.vim @@ -36,7 +36,7 @@ com! -bar CtrlPRoot cal ctrlp#init(0, { 'mode': 'r' }) exe 'nn (ctrlp) :'.g:ctrlp_cmd.'' if g:ctrlp_map != '' && !hasmapto('(ctrlp)') - exe 'map ' g:ctrlp_map '(ctrlp)' + exe 'map' g:ctrlp_map '(ctrlp)' en cal ctrlp#mrufiles#init() From dc33def9dfc304186ab751f41eff42fd07b52d99 Mon Sep 17 00:00:00 2001 From: Konfekt Date: Fri, 19 Dec 2014 17:50:02 +0100 Subject: [PATCH 40/67] add Work Dir MRU I really wanted this and was just about to write a CtrlPWorkDirMRU plugin before I stumbled upon the undocumented bang switch of CtrlPBookmarkDirAdd! --- doc/ctrlp.txt | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/doc/ctrlp.txt b/doc/ctrlp.txt index 4ed78ae8..2c45521a 100644 --- a/doc/ctrlp.txt +++ b/doc/ctrlp.txt @@ -1146,7 +1146,23 @@ Available extensions:~ - Name: 'bookmarkdir' - Commands: ":CtrlPBookmarkDir", ":CtrlPBookmarkDirAdd [directory]". + ":CtrlPBookmarkDirAdd!". + - Search for a bookmarked directory and change the working directory to it. + - Asks for a [TITLE] and the directory [directory] and adds [directory] under + the title [TITLE] to the CtrlPBookmarkDir list + - Add the current work dir [CWD] under the title [CWD] to the CtrlPBookmarkDir + list + + The last command can be used to add all recently used work dirs to the + CtrlPBookmarkDir list by an autocommand like + > + augroup CtrlPDirMRU + autocmd! + autocmd FileType * if &modifiable | execute 'silent CtrlPBookmarkDirAdd! %:p:h' | endif + augroup END + < + - Mappings: + change the local working directory for CtrlP, keep it open and switch to find file mode. From faafe125db65c4a3b9537a60a968e723b88a6c8f Mon Sep 17 00:00:00 2001 From: ludovicchabant Date: Mon, 18 Aug 2014 17:07:45 -0700 Subject: [PATCH 41/67] Add init function for custom ignore callbacks. --- autoload/ctrlp.vim | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/autoload/ctrlp.vim b/autoload/ctrlp.vim index 0c2850a9..64db3d67 100644 --- a/autoload/ctrlp.vim +++ b/autoload/ctrlp.vim @@ -343,6 +343,7 @@ fu! ctrlp#files() " Get the list of files if empty(lscmd) if !ctrlp#igncwd(s:dyncwd) + cal s:InitCustomFuncs() cal s:GlobPath(s:fnesc(s:dyncwd, 'g', ','), 0) en el @@ -369,6 +370,12 @@ fu! ctrlp#files() retu g:ctrlp_allfiles endf +fu! s:InitCustomFuncs() + if has_key(s:usrign, 'func-init') && s:usrign['func-init'] != '' + exe call(s:usrign['func-init'], []) + en +endf + fu! s:GlobPath(dirs, depth) let entries = split(globpath(a:dirs, s:glob), "\n") let [dnf, depth] = [ctrlp#dirnfile(entries), a:depth + 1] From d0fab7c72ccf1bcea48e531010cb7c45ede22f66 Mon Sep 17 00:00:00 2001 From: ludovicchabant Date: Thu, 29 Jan 2015 16:33:22 -0800 Subject: [PATCH 42/67] Add custom post-ignore function to mirror the init one. --- autoload/ctrlp.vim | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/autoload/ctrlp.vim b/autoload/ctrlp.vim index 64db3d67..fe1868d9 100644 --- a/autoload/ctrlp.vim +++ b/autoload/ctrlp.vim @@ -345,6 +345,7 @@ fu! ctrlp#files() if !ctrlp#igncwd(s:dyncwd) cal s:InitCustomFuncs() cal s:GlobPath(s:fnesc(s:dyncwd, 'g', ','), 0) + cal s:CloseCustomFuncs() en el sil! cal ctrlp#progress('Indexing...') @@ -376,6 +377,12 @@ fu! s:InitCustomFuncs() en endf +fu! s:CloseCustomFuncs() + if has_key(s:usrign, 'func-close') && s:usrign['func-close'] != '' + exe call(s:usrign['func-close'], []) + en +endf + fu! s:GlobPath(dirs, depth) let entries = split(globpath(a:dirs, s:glob), "\n") let [dnf, depth] = [ctrlp#dirnfile(entries), a:depth + 1] From 554af0130b753714948cb339ed10666611c071ec Mon Sep 17 00:00:00 2001 From: mattn Date: Mon, 2 Feb 2015 14:25:03 +0900 Subject: [PATCH 43/67] Check s:usrign is dictionary or string. Close #73 --- autoload/ctrlp.vim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/autoload/ctrlp.vim b/autoload/ctrlp.vim index fe1868d9..7318964b 100644 --- a/autoload/ctrlp.vim +++ b/autoload/ctrlp.vim @@ -372,13 +372,13 @@ fu! ctrlp#files() endf fu! s:InitCustomFuncs() - if has_key(s:usrign, 'func-init') && s:usrign['func-init'] != '' + if s:igntype == 4 && has_key(s:usrign, 'func-init') && s:usrign['func-init'] != '' exe call(s:usrign['func-init'], []) en endf fu! s:CloseCustomFuncs() - if has_key(s:usrign, 'func-close') && s:usrign['func-close'] != '' + if s:igntype == 4 && has_key(s:usrign, 'func-close') && s:usrign['func-close'] != '' exe call(s:usrign['func-close'], []) en endf From bc94048c41acaeaf3e4e9d4a6b3074a9f5cb9775 Mon Sep 17 00:00:00 2001 From: mattn Date: Mon, 2 Feb 2015 14:25:51 +0900 Subject: [PATCH 44/67] Fix indent --- autoload/ctrlp.vim | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/autoload/ctrlp.vim b/autoload/ctrlp.vim index 7318964b..00fc5353 100644 --- a/autoload/ctrlp.vim +++ b/autoload/ctrlp.vim @@ -378,9 +378,9 @@ fu! s:InitCustomFuncs() endf fu! s:CloseCustomFuncs() - if s:igntype == 4 && has_key(s:usrign, 'func-close') && s:usrign['func-close'] != '' - exe call(s:usrign['func-close'], []) - en + if s:igntype == 4 && has_key(s:usrign, 'func-close') && s:usrign['func-close'] != '' + exe call(s:usrign['func-close'], []) + en endf fu! s:GlobPath(dirs, depth) From f6cb0f07eb41ea47eb83efc2e75a123abbad6d10 Mon Sep 17 00:00:00 2001 From: Enno Nagel Date: Sat, 7 Feb 2015 15:17:15 +0100 Subject: [PATCH 45/67] remove typo to uniformize dir path --- autoload/ctrlp/bookmarkdir.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autoload/ctrlp/bookmarkdir.vim b/autoload/ctrlp/bookmarkdir.vim index 928d07f2..89f7695e 100644 --- a/autoload/ctrlp/bookmarkdir.vim +++ b/autoload/ctrlp/bookmarkdir.vim @@ -114,7 +114,7 @@ endf fu! ctrlp#bookmarkdir#add(bang, dir, ...) if a:bang == '!' - let cwd = fnamemodify(a:dir != '' ? a:dir : getcwd(), 'p') + let cwd = fnamemodify(a:dir != '' ? a:dir : getcwd(), ':p') let name = a:0 && a:1 != '' ? a:1 : cwd el let str = 'Directory to bookmark: ' From b37a761f0d99731b45a31754e82f2b4d2539b2f2 Mon Sep 17 00:00:00 2001 From: Enno Nagel Date: Sat, 7 Feb 2015 17:00:10 +0100 Subject: [PATCH 46/67] mru and bookmarked path use ~ for $HOME --- autoload/ctrlp/bookmarkdir.vim | 3 ++- autoload/ctrlp/mrufiles.vim | 6 ++++-- doc/ctrlp.txt | 10 +++++++++- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/autoload/ctrlp/bookmarkdir.vim b/autoload/ctrlp/bookmarkdir.vim index 89f7695e..e50eec92 100644 --- a/autoload/ctrlp/bookmarkdir.vim +++ b/autoload/ctrlp/bookmarkdir.vim @@ -114,7 +114,8 @@ endf fu! ctrlp#bookmarkdir#add(bang, dir, ...) if a:bang == '!' - let cwd = fnamemodify(a:dir != '' ? a:dir : getcwd(), ':p') + let cwd = fnamemodify(a:dir != '' ? a:dir : getcwd(), + \ g:ctrlp_mruf_tilde_homedir ? ':p:~' : ':p') let name = a:0 && a:1 != '' ? a:1 : cwd el let str = 'Directory to bookmark: ' diff --git a/autoload/ctrlp/mrufiles.vim b/autoload/ctrlp/mrufiles.vim index a1821114..0aa15376 100644 --- a/autoload/ctrlp/mrufiles.vim +++ b/autoload/ctrlp/mrufiles.vim @@ -15,6 +15,7 @@ fu! ctrlp#mrufiles#opts() \ 'case_sensitive': ['s:cseno', 1], \ 'relative': ['s:re', 0], \ 'save_on_update': ['s:soup', 1], + \ 'tilde_homedir': ['s:thd', 0], \ }] for [ke, va] in items(opts) let [{va[0]}, {pref.ke}] = [pref.ke, exists(pref.ke) ? {pref.ke} : va[1]] @@ -66,10 +67,11 @@ fu! s:record(bufnr) endf fu! s:addtomrufs(fname) - let fn = fnamemodify(a:fname, ':p') + let fn = fnamemodify(a:fname, g:ctrlp_mruf_tilde_homedir ? ':p:~' : ':p') let fn = exists('+ssl') ? tr(fn, '/', '\') : fn + let abs_fn = fnamemodify(fn,':p') if ( !empty({s:in}) && fn !~# {s:in} ) || ( !empty({s:ex}) && fn =~# {s:ex} ) - \ || !empty(getbufvar('^'.fn.'$', '&bt')) || !filereadable(fn) | retu + \ || !empty(getbufvar('^' . abs_fn . '$', '&bt')) || !filereadable(abs_fn) | retu en let idx = index(s:mrufs, fn, 0, !{s:cseno}) if idx diff --git a/doc/ctrlp.txt b/doc/ctrlp.txt index 2c45521a..c5ff0db9 100644 --- a/doc/ctrlp.txt +++ b/doc/ctrlp.txt @@ -70,6 +70,7 @@ Overview:~ |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_tilde_homedir|....Save MRU file paths in home dir as ~/. |ctrlp_mruf_default_order|....Disable sorting. |ctrlp_mruf_case_sensitive|...MRU files are case sensitive or not. |ctrlp_mruf_save_on_update|...Save to disk whenever a new entry is added. @@ -575,6 +576,14 @@ Example: > let g:ctrlp_mruf_include = '\.py$\|\.rb$' < + *'g:ctrlp_mruf_tilde_homedir'* +Set this to 1 to save every MRU file path $HOME/$filepath in the $HOME dir + as ~/$filepath instead of $HOME/$filepath : > + let g:ctrlp_mruf_tilde_homedir = 0 +< +Note: This applies also to all dir paths stored by :CtrlPBookmarkDirAdd! +< + *'g:ctrlp_mruf_relative'* Set this to 1 to show only MRU files in the current working directory: > let g:ctrlp_mruf_relative = 0 @@ -582,7 +591,6 @@ Set this to 1 to show only MRU files in the current working directory: > Note: you can use a custom mapping to toggle this option inside the prompt: > let g:ctrlp_prompt_mappings = { 'ToggleMRURelative()': [''] } < - *'g:ctrlp_mruf_default_order'* Set this to 1 to disable sorting when searching in MRU mode: > let g:ctrlp_mruf_default_order = 0 From 57216b07973a8e225aab06c289924ec847318d8f Mon Sep 17 00:00:00 2001 From: Enno Nagel Date: Tue, 10 Feb 2015 11:11:01 +0100 Subject: [PATCH 47/67] explain BookmarkDirAdd(!) command as provided --- doc/ctrlp.txt | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/doc/ctrlp.txt b/doc/ctrlp.txt index c5ff0db9..aec92664 100644 --- a/doc/ctrlp.txt +++ b/doc/ctrlp.txt @@ -1153,14 +1153,16 @@ Available extensions:~ * BookmarkDir mode:~ - Name: 'bookmarkdir' - Commands: ":CtrlPBookmarkDir", - ":CtrlPBookmarkDirAdd [directory]". - ":CtrlPBookmarkDirAdd!". + ":CtrlPBookmarkDirAdd [directory] [TITLE]". + ":CtrlPBookmarkDirAdd! [directory] [TITLE]". - Search for a bookmarked directory and change the working directory to it. - - Asks for a [TITLE] and the directory [directory] and adds [directory] under - the title [TITLE] to the CtrlPBookmarkDir list - - Add the current work dir [CWD] under the title [CWD] to the CtrlPBookmarkDir - list + - Add either the dir [directory], if supplied, or otherwise ask for it, + under the title given by either [TITLE], if supplied, or otherwise ask for + it, to the CtrlPBookmarkDir list. + - Add either the dir [directory], if supplied, or otherwise the current + work dir ( [CWD] ) under the title given by either [TITLE], if supplied, + or otherwise [CWD] to the CtrlPBookmarkDir list. The last command can be used to add all recently used work dirs to the CtrlPBookmarkDir list by an autocommand like From 7c22f7922b8d10e512f9aa26528cf08b544f4859 Mon Sep 17 00:00:00 2001 From: Enno Nagel Date: Tue, 10 Feb 2015 11:11:18 +0100 Subject: [PATCH 48/67] clean up BookmarkDirAdd function --- autoload/ctrlp/bookmarkdir.vim | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/autoload/ctrlp/bookmarkdir.vim b/autoload/ctrlp/bookmarkdir.vim index e50eec92..a0408f05 100644 --- a/autoload/ctrlp/bookmarkdir.vim +++ b/autoload/ctrlp/bookmarkdir.vim @@ -113,15 +113,14 @@ fu! ctrlp#bookmarkdir#accept(mode, str) endf fu! ctrlp#bookmarkdir#add(bang, dir, ...) + let cwd = fnamemodify(getcwd(), g:ctrlp_mruf_tilde_homedir ? ':p:~' : ':p') if a:bang == '!' - let cwd = fnamemodify(a:dir != '' ? a:dir : getcwd(), - \ g:ctrlp_mruf_tilde_homedir ? ':p:~' : ':p') + let cwd = fnamemodify(a:dir != '' ? a:dir : cwd) let name = a:0 && a:1 != '' ? a:1 : cwd el let str = 'Directory to bookmark: ' - let cwd = a:dir != '' ? a:dir : s:getinput(str, getcwd(), 'dir') + let cwd = a:dir != '' ? a:dir : s:getinput(str, cwd, 'dir') if cwd == '' | retu | en - let cwd = fnamemodify(cwd, ':p') let name = a:0 && a:1 != '' ? a:1 : s:getinput('Bookmark as: ', cwd) if name == '' | retu | en en From 3d30f36fea35b33f015d958256a3856a50bd8dfb Mon Sep 17 00:00:00 2001 From: Enno Nagel Date: Mon, 23 Feb 2015 19:05:21 +0100 Subject: [PATCH 49/67] make tilde_homedir variable global --- autoload/ctrlp.vim | 1 + autoload/ctrlp/bookmarkdir.vim | 7 ++++--- autoload/ctrlp/mrufiles.vim | 3 +-- doc/ctrlp.txt | 10 +++++----- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/autoload/ctrlp.vim b/autoload/ctrlp.vim index 00fc5353..649d9797 100644 --- a/autoload/ctrlp.vim +++ b/autoload/ctrlp.vim @@ -218,6 +218,7 @@ fu! s:opts(...) for each in ['byfname', 'regexp'] | if exists(each) let s:{each} = {each} en | endfo + if !exists('g:ctrlp_tilde_homedir') | let g:ctrlp_tilde_homedir = 0 | en if !exists('g:ctrlp_newcache') | let g:ctrlp_newcache = 0 | en let s:maxdepth = min([s:maxdepth, 100]) let s:glob = s:showhidden ? '.*\|*' : '*' diff --git a/autoload/ctrlp/bookmarkdir.vim b/autoload/ctrlp/bookmarkdir.vim index a0408f05..989ff7be 100644 --- a/autoload/ctrlp/bookmarkdir.vim +++ b/autoload/ctrlp/bookmarkdir.vim @@ -113,13 +113,14 @@ fu! ctrlp#bookmarkdir#accept(mode, str) endf fu! ctrlp#bookmarkdir#add(bang, dir, ...) - let cwd = fnamemodify(getcwd(), g:ctrlp_mruf_tilde_homedir ? ':p:~' : ':p') + let cwd = fnamemodify(getcwd(), g:ctrlp_tilde_homedir ? ':p:~' : ':p') + let dir = fnamemodify(a:dir, g:ctrlp_tilde_homedir ? ':p:~' : ':p') if a:bang == '!' - let cwd = fnamemodify(a:dir != '' ? a:dir : cwd) + let cwd = dir != '' ? dir : cwd let name = a:0 && a:1 != '' ? a:1 : cwd el let str = 'Directory to bookmark: ' - let cwd = a:dir != '' ? a:dir : s:getinput(str, cwd, 'dir') + let cwd = dir != '' ? dir : s:getinput(str, cwd, 'dir') if cwd == '' | retu | en let name = a:0 && a:1 != '' ? a:1 : s:getinput('Bookmark as: ', cwd) if name == '' | retu | en diff --git a/autoload/ctrlp/mrufiles.vim b/autoload/ctrlp/mrufiles.vim index 0aa15376..7d921510 100644 --- a/autoload/ctrlp/mrufiles.vim +++ b/autoload/ctrlp/mrufiles.vim @@ -15,7 +15,6 @@ fu! ctrlp#mrufiles#opts() \ 'case_sensitive': ['s:cseno', 1], \ 'relative': ['s:re', 0], \ 'save_on_update': ['s:soup', 1], - \ 'tilde_homedir': ['s:thd', 0], \ }] for [ke, va] in items(opts) let [{va[0]}, {pref.ke}] = [pref.ke, exists(pref.ke) ? {pref.ke} : va[1]] @@ -67,7 +66,7 @@ fu! s:record(bufnr) endf fu! s:addtomrufs(fname) - let fn = fnamemodify(a:fname, g:ctrlp_mruf_tilde_homedir ? ':p:~' : ':p') + let fn = fnamemodify(a:fname, g:ctrlp_tilde_homedir ? ':p:~' : ':p') let fn = exists('+ssl') ? tr(fn, '/', '\') : fn let abs_fn = fnamemodify(fn,':p') if ( !empty({s:in}) && fn !~# {s:in} ) || ( !empty({s:ex}) && fn =~# {s:ex} ) diff --git a/doc/ctrlp.txt b/doc/ctrlp.txt index aec92664..749a9416 100644 --- a/doc/ctrlp.txt +++ b/doc/ctrlp.txt @@ -70,7 +70,7 @@ Overview:~ |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_tilde_homedir|....Save MRU file paths in home dir as ~/. + |ctrlp_tilde_homedir|....Save MRU file paths in home dir as ~/. |ctrlp_mruf_default_order|....Disable sorting. |ctrlp_mruf_case_sensitive|...MRU files are case sensitive or not. |ctrlp_mruf_save_on_update|...Save to disk whenever a new entry is added. @@ -576,10 +576,10 @@ Example: > let g:ctrlp_mruf_include = '\.py$\|\.rb$' < - *'g:ctrlp_mruf_tilde_homedir'* + *'g:ctrlp_tilde_homedir'* Set this to 1 to save every MRU file path $HOME/$filepath in the $HOME dir as ~/$filepath instead of $HOME/$filepath : > - let g:ctrlp_mruf_tilde_homedir = 0 + let g:ctrlp_tilde_homedir = 0 < Note: This applies also to all dir paths stored by :CtrlPBookmarkDirAdd! < @@ -1164,7 +1164,7 @@ Available extensions:~ work dir ( [CWD] ) under the title given by either [TITLE], if supplied, or otherwise [CWD] to the CtrlPBookmarkDir list. - The last command can be used to add all recently used work dirs to the + The last command can be used to add all recently used work dirs to the CtrlPBookmarkDir list by an autocommand like > augroup CtrlPDirMRU @@ -1172,7 +1172,7 @@ Available extensions:~ autocmd FileType * if &modifiable | execute 'silent CtrlPBookmarkDirAdd! %:p:h' | endif augroup END < - + - Mappings: + change the local working directory for CtrlP, keep it open and switch to find file mode. From 0d1b1788051bad0dfa234832e3130bad2289efab Mon Sep 17 00:00:00 2001 From: walt Date: Fri, 27 Feb 2015 06:07:56 +0100 Subject: [PATCH 50/67] added option g:open_single_match --- autoload/ctrlp.vim | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/autoload/ctrlp.vim b/autoload/ctrlp.vim index 00fc5353..dbbd0918 100644 --- a/autoload/ctrlp.vim +++ b/autoload/ctrlp.vim @@ -88,6 +88,7 @@ let [s:pref, s:bpref, s:opts, s:new_opts, s:lc_opts] = \ 'use_caching': ['s:caching', 1], \ 'user_command': ['s:usrcmd', ''], \ 'working_path_mode': ['s:pathmode', 'ra'], + \ 'open_single_match': ['s:opensingle', 0], \ }, { \ 'open_multiple_files': 's:opmul', \ 'regexp': 's:regexp', @@ -593,6 +594,7 @@ fu! s:Update(str) let lines = s:nolim == 1 && empty(str) ? copy(g:ctrlp_lines) \ : s:MatchedItems(g:ctrlp_lines, pat, s:mw_res) cal s:Render(lines, pat) + return lines endf fu! s:ForceUpdate() @@ -2319,6 +2321,15 @@ fu! ctrlp#setlines(...) let g:ctrlp_lines = eval(types[s:itemtype]) endf +fu! s:exitIfSingleCandidate() + if len(s:Update(s:prompt[0])) == 1 + call s:AcceptSelection('e') + call ctrlp#exit() + return 1 + endif + return 0 +endfu + fu! ctrlp#init(type, ...) if exists('s:init') || s:iscmdwin() | retu | en let [s:ermsg, v:errmsg] = [v:errmsg, ''] @@ -2331,8 +2342,12 @@ fu! ctrlp#init(type, ...) cal ctrlp#syntax() cal ctrlp#setlines(s:settype(a:type)) cal s:SetDefTxt() + if s:opensingle && s:exitIfSingleCandidate() + return 0 + endif cal s:BuildPrompt(1) if s:keyloop | cal s:KeyLoop() | en + return 1 endf " - Autocmds {{{1 if has('autocmd') From 99905702ee3203d7343f69849ad380c074fc32af Mon Sep 17 00:00:00 2001 From: walt Date: Fri, 27 Feb 2015 13:12:14 +0100 Subject: [PATCH 51/67] added option g:ctrlp_line_prefix, defining a string to print in front of each line. Default: '> ' --- autoload/ctrlp.vim | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/autoload/ctrlp.vim b/autoload/ctrlp.vim index 00fc5353..e0cfc1d8 100644 --- a/autoload/ctrlp.vim +++ b/autoload/ctrlp.vim @@ -88,6 +88,7 @@ let [s:pref, s:bpref, s:opts, s:new_opts, s:lc_opts] = \ 'use_caching': ['s:caching', 1], \ 'user_command': ['s:usrcmd', ''], \ 'working_path_mode': ['s:pathmode', 'ra'], + \ 'line_prefix': ['s:lineprefix', '> '], \ }, { \ 'open_multiple_files': 's:opmul', \ 'regexp': 's:regexp', @@ -1457,7 +1458,7 @@ fu! s:formatline(str) let str .= idc != '' ? ' '.idc : '' en let cond = s:ispath && ( s:winw - 4 ) < s:strwidth(str) - retu '> '.( cond ? s:pathshorten(str) : str ) + retu s:lineprefix.( cond ? s:pathshorten(str) : str ) endf fu! s:pathshorten(str) From 3c4f108a7bbf1ceaafd9a5ef360d545e2c29de76 Mon Sep 17 00:00:00 2001 From: Konfekt Date: Sun, 8 Mar 2015 14:24:19 +0100 Subject: [PATCH 52/67] add option to prevent adding nomod buffers to MRU --- autoload/ctrlp/mrufiles.vim | 5 ++++- doc/ctrlp.txt | 6 ++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/autoload/ctrlp/mrufiles.vim b/autoload/ctrlp/mrufiles.vim index 7d921510..70d1f6aa 100644 --- a/autoload/ctrlp/mrufiles.vim +++ b/autoload/ctrlp/mrufiles.vim @@ -15,6 +15,7 @@ fu! ctrlp#mrufiles#opts() \ 'case_sensitive': ['s:cseno', 1], \ 'relative': ['s:re', 0], \ 'save_on_update': ['s:soup', 1], + \ 'exclude_nomod': ['s:exclnomod', 0], \ }] for [ke, va] in items(opts) let [{va[0]}, {pref.ke}] = [pref.ke, exists(pref.ke) ? {pref.ke} : va[1]] @@ -55,6 +56,8 @@ fu! s:reformat(mrufs, ...) endf fu! s:record(bufnr) + if s:exclnomod && &l:modifiable | retu | en + if s:exclnomod && !&l:modifiable | retu | en if s:locked | retu | en let bufnr = a:bufnr + 0 let bufname = bufname(bufnr) @@ -144,7 +147,7 @@ fu! ctrlp#mrufiles#init() let s:locked = 0 aug CtrlPMRUF au! - au BufAdd,BufEnter,BufLeave,BufWritePost * cal s:record(expand('', 1)) + au BufWinEnter,BufWinLeave,BufWritePost * cal s:record(expand('', 1)) au QuickFixCmdPre *vimgrep* let s:locked = 1 au QuickFixCmdPost *vimgrep* let s:locked = 0 au VimLeavePre * cal s:savetofile(s:mergelists()) diff --git a/doc/ctrlp.txt b/doc/ctrlp.txt index 749a9416..7538d0c4 100644 --- a/doc/ctrlp.txt +++ b/doc/ctrlp.txt @@ -74,6 +74,7 @@ Overview:~ |ctrlp_mruf_default_order|....Disable sorting. |ctrlp_mruf_case_sensitive|...MRU files are case sensitive or not. |ctrlp_mruf_save_on_update|...Save to disk whenever a new entry is added. + |ctrlp_mruf_exclude_nomod|....Exclude nonmodifiable buffers from the MRU list. BufferTag mode: (to enable, see |ctrlp-extensions|) |g:ctrlp_buftag_ctags_bin|....The location of the ctags-compatible binary. @@ -608,6 +609,11 @@ entry is added, saving will then only occur when exiting Vim: > let g:ctrlp_mruf_save_on_update = 1 < + *'g:ctrlp_mruf_exclude_nomod'* +Set this to 1 to disable adding nonmodifiable buffers, for example help files, +to the MRU list: > + let g:ctrlp_mruf_exclude_nomod = 0 +< ---------------------------------------- Advanced options:~ From ff673566bc93634810b428f30d6f0a1cd194e85e Mon Sep 17 00:00:00 2001 From: Yasuhiro Matsumoto Date: Mon, 9 Mar 2015 12:54:35 +0900 Subject: [PATCH 53/67] Fix bug. related issue #82 --- autoload/ctrlp/bookmarkdir.vim | 5 +++-- autoload/ctrlp/mrufiles.vim | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/autoload/ctrlp/bookmarkdir.vim b/autoload/ctrlp/bookmarkdir.vim index 989ff7be..f7fc14dc 100644 --- a/autoload/ctrlp/bookmarkdir.vim +++ b/autoload/ctrlp/bookmarkdir.vim @@ -113,8 +113,9 @@ fu! ctrlp#bookmarkdir#accept(mode, str) endf fu! ctrlp#bookmarkdir#add(bang, dir, ...) - let cwd = fnamemodify(getcwd(), g:ctrlp_tilde_homedir ? ':p:~' : ':p') - let dir = fnamemodify(a:dir, g:ctrlp_tilde_homedir ? ':p:~' : ':p') + let ctrlp_tilde_homedir = get(g:, 'ctrlp_tilde_homedir', 0) + let cwd = fnamemodify(getcwd(), ctrlp_tilde_homedir ? ':p:~' : ':p') + let dir = fnamemodify(a:dir, ctrlp_tilde_homedir ? ':p:~' : ':p') if a:bang == '!' let cwd = dir != '' ? dir : cwd let name = a:0 && a:1 != '' ? a:1 : cwd diff --git a/autoload/ctrlp/mrufiles.vim b/autoload/ctrlp/mrufiles.vim index 70d1f6aa..0774c132 100644 --- a/autoload/ctrlp/mrufiles.vim +++ b/autoload/ctrlp/mrufiles.vim @@ -69,7 +69,7 @@ fu! s:record(bufnr) endf fu! s:addtomrufs(fname) - let fn = fnamemodify(a:fname, g:ctrlp_tilde_homedir ? ':p:~' : ':p') + let fn = fnamemodify(a:fname, get(g:, 'ctrlp_tilde_homedir', 0) ? ':p:~' : ':p') let fn = exists('+ssl') ? tr(fn, '/', '\') : fn let abs_fn = fnamemodify(fn,':p') if ( !empty({s:in}) && fn !~# {s:in} ) || ( !empty({s:ex}) && fn =~# {s:ex} ) From 193d1764d7ff0ae69eddb06ee8c92d7697b213dc Mon Sep 17 00:00:00 2001 From: walt Date: Thu, 12 Mar 2015 13:53:36 +0100 Subject: [PATCH 54/67] made g:ctrlp_open_single into a list of affected extensions, rather than a global setting --- autoload/ctrlp.vim | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/autoload/ctrlp.vim b/autoload/ctrlp.vim index dbbd0918..1f119c0f 100644 --- a/autoload/ctrlp.vim +++ b/autoload/ctrlp.vim @@ -88,7 +88,7 @@ let [s:pref, s:bpref, s:opts, s:new_opts, s:lc_opts] = \ 'use_caching': ['s:caching', 1], \ 'user_command': ['s:usrcmd', ''], \ 'working_path_mode': ['s:pathmode', 'ra'], - \ 'open_single_match': ['s:opensingle', 0], + \ 'open_single_match': ['s:opensingle', []], \ }, { \ 'open_multiple_files': 's:opmul', \ 'regexp': 's:regexp', @@ -2321,7 +2321,7 @@ fu! ctrlp#setlines(...) let g:ctrlp_lines = eval(types[s:itemtype]) endf -fu! s:exitIfSingleCandidate() +fu! s:ExitIfSingleCandidate() if len(s:Update(s:prompt[0])) == 1 call s:AcceptSelection('e') call ctrlp#exit() @@ -2342,7 +2342,7 @@ fu! ctrlp#init(type, ...) cal ctrlp#syntax() cal ctrlp#setlines(s:settype(a:type)) cal s:SetDefTxt() - if s:opensingle && s:exitIfSingleCandidate() + if index(s:opensingle, s:getextvar("lname"))>=0 && s:ExitIfSingleCandidate() return 0 endif cal s:BuildPrompt(1) From 682f6e155ae43aff5ac264ad23629018edc096bc Mon Sep 17 00:00:00 2001 From: walt Date: Thu, 12 Mar 2015 19:36:16 +0100 Subject: [PATCH 55/67] made g:open_single_match work for core modes also --- autoload/ctrlp.vim | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/autoload/ctrlp.vim b/autoload/ctrlp.vim index 1f119c0f..577d0892 100644 --- a/autoload/ctrlp.vim +++ b/autoload/ctrlp.vim @@ -182,6 +182,14 @@ let s:hlgrps = { \ 'PrtText': 'Normal', \ 'PrtCursor': 'Constant', \ } + +" lname, sname of the basic(non-extension) modes +let s:coretypes = [ + \ ['files', 'fil'], + \ ['buffers', 'buf'], + \ ['mru files', 'mru'], +\ ] + " Get the options {{{2 fu! s:opts(...) unl! s:usrign s:usrcmd s:urprtmaps @@ -1384,11 +1392,7 @@ endf " Statusline {{{2 fu! ctrlp#statusline() if !exists('s:statypes') - let s:statypes = [ - \ ['files', 'fil'], - \ ['buffers', 'buf'], - \ ['mru files', 'mru'], - \ ] + let s:statypes = copy(s:coretypes) if !empty(g:ctrlp_ext_vars) cal map(copy(g:ctrlp_ext_vars), \ 'add(s:statypes, [ v:val["lname"], v:val["sname"] ])') @@ -2321,6 +2325,15 @@ fu! ctrlp#setlines(...) let g:ctrlp_lines = eval(types[s:itemtype]) endf +" Returns [lname, sname] +fu! s:CurTypeName() + if s:itemtype < 3 + return s:coretypes[s:itemtype] + else + return [s:getextvar("lname"), s:getextvar('sname')] + endif +endfu + fu! s:ExitIfSingleCandidate() if len(s:Update(s:prompt[0])) == 1 call s:AcceptSelection('e') @@ -2342,7 +2355,9 @@ fu! ctrlp#init(type, ...) cal ctrlp#syntax() cal ctrlp#setlines(s:settype(a:type)) cal s:SetDefTxt() - if index(s:opensingle, s:getextvar("lname"))>=0 && s:ExitIfSingleCandidate() + let curName = s:CurTypeName() + let shouldExitSingle = index(s:opensingle, curName[0])>=0 || index(s:opensingle, curName[1])>=0 + if shouldExitSingle && s:ExitIfSingleCandidate() return 0 endif cal s:BuildPrompt(1) From 6415ca19529d71b88c071791d2c970c7a9c1ba70 Mon Sep 17 00:00:00 2001 From: LFDM <1986gh@gmail.com> Date: Sun, 4 Jan 2015 07:59:38 +0100 Subject: [PATCH 56/67] Add new extensions function: update Allows to manipulate the user's input string just before it is used with the matching algorithm. --- autoload/ctrlp.vim | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/autoload/ctrlp.vim b/autoload/ctrlp.vim index 0eabc5f2..841900ba 100644 --- a/autoload/ctrlp.vim +++ b/autoload/ctrlp.vim @@ -590,6 +590,9 @@ fu! s:Update(str) let str = s:sanstail(a:str) " Stop if the string's unchanged if str == oldstr && !empty(str) && !exists('s:force') | retu | en + " Optionally send the string to an extensions update function + let ext_update = s:getextvar('update') + if ext_update != -1 | let str = call(ext_update, [str]) | en let s:martcs = &scs && str =~ '\u' ? '\C' : '' let pat = s:matcher == {} ? s:SplitPattern(str) : str let lines = s:nolim == 1 && empty(str) ? copy(g:ctrlp_lines) @@ -2336,6 +2339,7 @@ fu! ctrlp#init(type, ...) cal s:BuildPrompt(1) if s:keyloop | cal s:KeyLoop() | en endf + " - Autocmds {{{1 if has('autocmd') aug CtrlPAug From 8bf346cf9961d69114ab04b9d18346799a714440 Mon Sep 17 00:00:00 2001 From: Ludovic Chabant Date: Sun, 15 Mar 2015 21:28:42 -0700 Subject: [PATCH 57/67] Rename `update` to `validate`. --- autoload/ctrlp.vim | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/autoload/ctrlp.vim b/autoload/ctrlp.vim index 841900ba..0c05698e 100644 --- a/autoload/ctrlp.vim +++ b/autoload/ctrlp.vim @@ -87,6 +87,7 @@ let [s:pref, s:bpref, s:opts, s:new_opts, s:lc_opts] = \ 'tabpage_position': ['s:tabpage', 'ac'], \ 'use_caching': ['s:caching', 1], \ 'user_command': ['s:usrcmd', ''], + \ 'validate': ['s:validate', ''], \ 'working_path_mode': ['s:pathmode', 'ra'], \ 'line_prefix': ['s:lineprefix', '> '], \ }, { @@ -590,9 +591,8 @@ fu! s:Update(str) let str = s:sanstail(a:str) " Stop if the string's unchanged if str == oldstr && !empty(str) && !exists('s:force') | retu | en - " Optionally send the string to an extensions update function - let ext_update = s:getextvar('update') - if ext_update != -1 | let str = call(ext_update, [str]) | en + " Optionally send the string to a custom validate function + if s:validate != '' | let str = call(s:validate, [str]) | en let s:martcs = &scs && str =~ '\u' ? '\C' : '' let pat = s:matcher == {} ? s:SplitPattern(str) : str let lines = s:nolim == 1 && empty(str) ? copy(g:ctrlp_lines) @@ -2339,7 +2339,6 @@ fu! ctrlp#init(type, ...) cal s:BuildPrompt(1) if s:keyloop | cal s:KeyLoop() | en endf - " - Autocmds {{{1 if has('autocmd') aug CtrlPAug From 51888616a29eeddc933d8ec0596bd13e83231b90 Mon Sep 17 00:00:00 2001 From: Yasuhiro Matsumoto Date: Mon, 16 Mar 2015 13:38:13 +0900 Subject: [PATCH 58/67] Fix indent --- autoload/ctrlp.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autoload/ctrlp.vim b/autoload/ctrlp.vim index 0c05698e..6d70535d 100644 --- a/autoload/ctrlp.vim +++ b/autoload/ctrlp.vim @@ -87,7 +87,7 @@ let [s:pref, s:bpref, s:opts, s:new_opts, s:lc_opts] = \ 'tabpage_position': ['s:tabpage', 'ac'], \ 'use_caching': ['s:caching', 1], \ 'user_command': ['s:usrcmd', ''], - \ 'validate': ['s:validate', ''], + \ 'validate': ['s:validate', ''], \ 'working_path_mode': ['s:pathmode', 'ra'], \ 'line_prefix': ['s:lineprefix', '> '], \ }, { From 74e8de7632d409ac6598d5c9dbfbbe01c09600fa Mon Sep 17 00:00:00 2001 From: Michael Maurizi Date: Mon, 16 Mar 2015 19:16:50 -0400 Subject: [PATCH 59/67] Fix auto selection of tag from tselect menu for tags in the same file. Starting with commit 83397bd0, when possible Ctrlp tries to autoselect a tag from from the `tselect` menu. This has a significant flaw though, as it does not select the correct tag when there are multiple tags with the same name in the same file, instead preferring to always use the last tag from that file. By matching not just on filename of the selected tag, but also on the tagaddress (generally a regex or linenumber), we ensure that the correct tag is always selected from the tselect prompt. --- autoload/ctrlp/tag.vim | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/autoload/ctrlp/tag.vim b/autoload/ctrlp/tag.vim index fa8c732f..31504dcc 100644 --- a/autoload/ctrlp/tag.vim +++ b/autoload/ctrlp/tag.vim @@ -21,7 +21,7 @@ cal add(g:ctrlp_ext_vars, { let s:id = g:ctrlp_builtins + len(g:ctrlp_ext_vars) " Utilities {{{1 -fu! s:findcount(str) +fu! s:findcount(str, tgaddr) let [tg, ofname] = split(a:str, '\t\+\ze[^\t]\+$') let tgs = taglist('^'.tg.'$') if len(tgs) < 2 @@ -48,7 +48,13 @@ fu! s:findcount(str) for tgi in ntgs let cnt += 1 if tgi["filename"] == ofname - let [fnd, pos] = [0, cnt] + if a:tgaddr != "" + if a:tgaddr == tgi["cmd"] + let [fnd, pos] = [0, cnt] + en + else + let [fnd, pos] = [0, cnt] + en en endfo retu [1, fnd, pos, len(ctgs)] @@ -92,8 +98,9 @@ endf fu! ctrlp#tag#accept(mode, str) cal ctrlp#exit() + let tgaddr = matchstr(a:str, '^[^\t]\+\t\+[^\t]\+\t\zs[^\t]\{-1,}\ze\%(;"\)\?\t') let str = matchstr(a:str, '^[^\t]\+\t\+[^\t]\+\ze\t') - let [tg, fdcnt] = [split(str, '^[^\t]\+\zs\t')[0], s:findcount(str)] + let [tg, fdcnt] = [split(str, '^[^\t]\+\zs\t')[0], s:findcount(str, tgaddr)] let cmds = { \ 't': ['tab sp', 'tab stj'], \ 'h': ['sp', 'stj'], From dfd357ca9d8459a604ca26d3bb1f896b26398824 Mon Sep 17 00:00:00 2001 From: Ferran Pelayo Monfort Date: Mon, 30 Mar 2015 18:13:44 +0200 Subject: [PATCH 60/67] Add support for terminal buffers on neovim Add function s:isneovimterminal --- autoload/ctrlp.vim | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/autoload/ctrlp.vim b/autoload/ctrlp.vim index 19ac1463..4d054846 100644 --- a/autoload/ctrlp.vim +++ b/autoload/ctrlp.vim @@ -440,8 +440,8 @@ fu! s:lsCmd() endf " - Buffers {{{1 fu! ctrlp#buffers(...) - let ids = sort(filter(range(1, bufnr('$')), 'empty(getbufvar(v:val, "&bt"))' - \ .' && getbufvar(v:val, "&bl")'), 's:compmreb') + let ids = sort(filter(range(1, bufnr('$')), '(empty(getbufvar(v:val, "&bt"))' + \ .' || s:isneovimterminal(v:val)) && getbufvar(v:val, "&bl")'), 's:compmreb') if a:0 && a:1 == 'id' retu ids el @@ -1743,7 +1743,7 @@ endf fu! ctrlp#normcmd(cmd, ...) if a:0 < 2 && s:nosplit() | retu a:cmd | en let norwins = filter(range(1, winnr('$')), - \ 'empty(getbufvar(winbufnr(v:val), "&bt"))') + \ 'empty(getbufvar(winbufnr(v:val), "&bt")) || s:isneovimterminal(v:val)') for each in norwins let bufnr = winbufnr(each) if empty(bufname(bufnr)) && empty(getbufvar(bufnr, '&ft')) @@ -2005,6 +2005,10 @@ fu! s:delent(rfunc) cal s:BuildPrompt(1) unl s:force endf + +fu! s:isneovimterminal(buf) + retu has('nvim') && getbufvar(a:buf, "&bt") == "terminal" +endf " Entering & Exiting {{{2 fu! s:getenv() let [s:cwd, s:winres] = [getcwd(), [winrestcmd(), &lines, winnr('$')]] From 5ab5b0d56603d2350c02dbe3256c49c870bc1069 Mon Sep 17 00:00:00 2001 From: codepiano Date: Sun, 28 Jun 2015 10:33:54 +0800 Subject: [PATCH 61/67] translate recent help doc changes --- doc/ctrlp.cnx | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/doc/ctrlp.cnx b/doc/ctrlp.cnx index 66266675..3daf91c3 100644 --- a/doc/ctrlp.cnx +++ b/doc/ctrlp.cnx @@ -78,9 +78,11 @@ OPTIONS *ctrlp-options* |ctrlp_mruf_exclude|..........需要被排除的文件。 |ctrlp_mruf_include|..........需要被记录的文件。 |ctrlp_mruf_relative|.........只显示在工作目录内的最近最多使用。 + |ctrlp_tilde_homedir|.........保存 home 目录中的 MRU 的目录路径为波浪扩展的形式 ~/。 |ctrlp_mruf_default_order|....禁用排序。 |ctrlp_mruf_case_sensitive|...最近最多使用文件是否大小写敏感。 |ctrlp_mruf_save_on_update|...只要有一个新的条目添加,就保存到磁盘。 + |ctrlp_mruf_exclude_nomod|....从 MRU 中排除不可编辑的缓冲区。 缓冲区标签模式: (开启此模式,参考 |ctrlp-extensions| ) |g:ctrlp_buftag_ctags_bin|....兼容的ctags二进制程序的位置。 @@ -552,6 +554,12 @@ MRU mode options:~ 例子: > let g:ctrlp_mruf_include = '\.py$\|\.rb$' < + *'g:ctrlp_tilde_homedir'* +将这个选项设置为1来把所有的 MRU 文件路径中 $HOME 目录下的 $HOME/$filepath 保存 +为 ~/$filepath ,而不是 $HOME/$filepath : > + let g:ctrlp_tilde_homedir = 0 +< +注意: 对所有通过 :CtrlPBookmarkDirAdd! 保存的也有效 *'g:ctrlp_mruf_relative'* 设置该选项为1将只显示在当前工作目录内的最近最多使用文件: > @@ -577,6 +585,10 @@ MRU mode options:~ let g:ctrlp_mruf_save_on_update = 1 < + *'g:ctrlp_mruf_exclude_nomod'* +将这个选项设置为1来禁止添加不可编辑的缓冲区,例如帮助文件,到 MRU 列表: > + let g:ctrlp_mruf_exclude_nomod = 0 +< ---------------------------------------- 高级选项:~ @@ -1084,7 +1096,7 @@ h) 使用?打开帮助文件。 * 修改列表模式:~ - 名称: 'changes' - 命令: ":CtrlPChange [缓冲区]", - ":CtrlPChangeAll". + ":CtrlPChangeAll". - 在当前缓冲区或者在所有列出的缓冲区内搜索最近的修改并跳转。 *:CtrlPMixed* @@ -1098,8 +1110,23 @@ h) 使用?打开帮助文件。 * 书签目录模式:~ - 名称: 'bookmarkdir' - 命令: ":CtrlPBookmarkDir", - ":CtrlPBookmarkDirAdd [目录]". + ":CtrlPBookmarkDirAdd [目录] [标题]". + ":CtrlPBookmarkDirAdd! [目录] [标题]". - 搜索一个被书签标记的目录并将其作为工作目录。 + - 以指定的[标题]添加[目录]到 CtrlPBookmarkDir 中,如果没有给出[标题]或 + 者[目录],会请求用户输入。 + - 以指定的[标题]添加[目录]到 CtrlPBookmarkDir 中,如果没有给出目录,则 + 默认为当前目录( [CWD] ),如果没有给出[标题] ,会请求用户输入。 + + 最新的用来添加所有最近使用过的目录到 CtrlPBookmarkDir 列表中的自动命令 + 如下 + > + augroup CtrlPDirMRU + autocmd! + autocmd FileType * if &modifiable | execute 'silent CtrlPBookmarkDirAdd! %:p:h' | endif + augroup END +< + - 按键绑定: + 为CtrlP修改工作目录并且保持打开状态,并且切换到文件搜索模式。 + 修改全局的工作目录(退出)。 From 7fcd2b4e1bfb7247de6dc164a64426798e7cd5f3 Mon Sep 17 00:00:00 2001 From: walt Date: Thu, 13 Aug 2015 07:15:08 +0200 Subject: [PATCH 62/67] documentation for g:ctrlp_open_single_match and g:ctrpl_ctrlp_line_prefix --- doc/ctrlp.txt | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/doc/ctrlp.txt b/doc/ctrlp.txt index 7538d0c4..774ddb84 100644 --- a/doc/ctrlp.txt +++ b/doc/ctrlp.txt @@ -64,6 +64,8 @@ Overview:~ |ctrlp_abbrev|................Input abbreviations. |ctrlp_key_loop|..............Use input looping for multi-byte input. |ctrlp_prompt_mappings|.......Change the mappings inside the prompt. + |ctrlp_line_prefix|...........Prefix for each line in ctrlp window. + |ctrlp_open_single_match|.....Automatically accept when only one candidate. MRU mode: |ctrlp_mruf_max|..............Max MRU entries to remember. @@ -443,6 +445,7 @@ 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' < +This option works well together with |g:ctrlp_open_single_match| *'g:ctrlp_abbrev'* Define input abbreviations that can be expanded (either internally or visibly) @@ -552,6 +555,34 @@ default mapping: > let g:ctrlp_prompt_mappings = { 'PrtCurLeft()': ['', ''] } < + *'g:ctrlp_line_prefix'* +This prefix will be prepended to each line in ctrlp's item listing. +default: > + let g:ctrlp_line_prefix = '> ' +< + + *'g:ctrlp_open_single_match'* +List of CtrlP modes for which CtrlP should accept an entry directly, if only +one candidate exists. +Example: > + let g:ctrlp_open_single_match = ['buffer tags', 'buffer'] +< +This is currently only really useful together with |g:ctrlp_default_input| +set before launching, and cleared afterwards, with a function such as +following: > + fu! tagsUnderCursor() + try + let default_input_save = get(g:, 'ctrlp_default_input', '') + let g:ctrlp_default_input = expand('') + CtrlPBufTagAll + finally + if exists('default_input_save') + let g:ctrlp_default_input = default_input_save + endif + endtry + endfu +> +< ---------------------------------------- MRU mode options:~ From d82ec243798ea60556ef1729d8e9f741bc867ad6 Mon Sep 17 00:00:00 2001 From: Takahiro Yoshihara Date: Thu, 20 Aug 2015 10:39:06 +0900 Subject: [PATCH 63/67] Fix buffer mode to handle neovim terminal buffer properly (#106) --- autoload/ctrlp.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autoload/ctrlp.vim b/autoload/ctrlp.vim index a05013d4..64e68520 100644 --- a/autoload/ctrlp.vim +++ b/autoload/ctrlp.vim @@ -1839,7 +1839,7 @@ endf fu! ctrlp#normcmd(cmd, ...) if a:0 < 2 && s:nosplit() | retu a:cmd | en let norwins = filter(range(1, winnr('$')), - \ 'empty(getbufvar(winbufnr(v:val), "&bt")) || s:isneovimterminal(v:val)') + \ 'empty(getbufvar(winbufnr(v:val), "&bt")) || s:isneovimterminal(winbufnr(v:val))') for each in norwins let bufnr = winbufnr(each) if empty(bufname(bufnr)) && empty(getbufvar(bufnr, '&ft')) From 273132bcfb4af188e45938c491cf7606f7d066b8 Mon Sep 17 00:00:00 2001 From: Syohei YOSHIDA Date: Wed, 26 Aug 2015 15:18:46 +0900 Subject: [PATCH 64/67] Correct misspellings --- doc/ctrlp.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/ctrlp.txt b/doc/ctrlp.txt index 774ddb84..9d6ca02a 100644 --- a/doc/ctrlp.txt +++ b/doc/ctrlp.txt @@ -121,7 +121,7 @@ Set this to 1 to set regexp search as the default: > Can be toggled on/off by pressing inside the prompt. *'g:ctrlp_match_window'* -Change the postion, the listing order of results, the minimum and the maximum +Change the position, the listing order of results, the minimum and the maximum heights of the match window: > let g:ctrlp_match_window = '' < @@ -1079,7 +1079,7 @@ d) Submit two dots '..' to go upward the directory tree by 1 level. To go up e) Similarly, submit '/' or '\' to find and go to the project's root. If the project is large, using a VCS listing command to look for files - might help speeding up the intial scan (see |g:ctrlp_user_command| for more + might help speeding up the initial scan (see |g:ctrlp_user_command| for more details). Note: d) and e) only work in file, directory and mixed modes. From c857aa138dacfc38ee8e84e13cca50d941d9152d Mon Sep 17 00:00:00 2001 From: ptzz Date: Mon, 14 Sep 2015 09:56:34 +0200 Subject: [PATCH 65/67] Add support for ant and tex files in buffertag --- autoload/ctrlp/buffertag.vim | 2 ++ 1 file changed, 2 insertions(+) diff --git a/autoload/ctrlp/buffertag.vim b/autoload/ctrlp/buffertag.vim index 6f3144ea..db22615e 100644 --- a/autoload/ctrlp/buffertag.vim +++ b/autoload/ctrlp/buffertag.vim @@ -43,6 +43,7 @@ let s:bins = [ \ ] let s:types = { + \ 'ant' : '%sant%sant%spt', \ 'asm' : '%sasm%sasm%sdlmt', \ 'aspperl': '%sasp%sasp%sfsv', \ 'aspvbs' : '%sasp%sasp%sfsv', @@ -77,6 +78,7 @@ let s:types = { \ 'slang' : '%sslang%sslang%snf', \ 'sml' : '%ssml%ssml%secsrtvf', \ 'sql' : '%ssql%ssql%scFPrstTvfp', + \ 'tex' : '%stex%stex%sipcsubPGl', \ 'tcl' : '%stcl%stcl%scfmp', \ 'vera' : '%svera%svera%scdefgmpPtTvx', \ 'verilog': '%sverilog%sverilog%smcPertwpvf', From fd18d37b4e05493f3892bfee3ead87bb536f4559 Mon Sep 17 00:00:00 2001 From: ptzz Date: Mon, 14 Sep 2015 14:27:55 +0200 Subject: [PATCH 66/67] Add buffertag support for dosbatch, matlab and vhdl --- autoload/ctrlp/buffertag.vim | 3 +++ 1 file changed, 3 insertions(+) diff --git a/autoload/ctrlp/buffertag.vim b/autoload/ctrlp/buffertag.vim index db22615e..95d79880 100644 --- a/autoload/ctrlp/buffertag.vim +++ b/autoload/ctrlp/buffertag.vim @@ -53,6 +53,7 @@ let s:types = { \ 'cpp' : '%sc++%sc++%snvdtcgsuf', \ 'cs' : '%sc#%sc#%sdtncEgsipm', \ 'cobol' : '%scobol%scobol%sdfgpPs', + \ 'dosbatch': '%sdosbatch%sdosbatch%slv', \ 'eiffel' : '%seiffel%seiffel%scf', \ 'erlang' : '%serlang%serlang%sdrmf', \ 'expect' : '%stcl%stcl%scfp', @@ -63,6 +64,7 @@ let s:types = { \ 'lisp' : '%slisp%slisp%sf', \ 'lua' : '%slua%slua%sf', \ 'make' : '%smake%smake%sm', + \ 'matlab' : '%smatlab%smatlab%sf', \ 'ocaml' : '%socaml%socaml%scmMvtfCre', \ 'pascal' : '%spascal%spascal%sfp', \ 'perl' : '%sperl%sperl%sclps', @@ -82,6 +84,7 @@ let s:types = { \ 'tcl' : '%stcl%stcl%scfmp', \ 'vera' : '%svera%svera%scdefgmpPtTvx', \ 'verilog': '%sverilog%sverilog%smcPertwpvf', + \ 'vhdl' : '%svhdl%svhdl%sPctTrefp', \ 'vim' : '%svim%svim%savf', \ 'yacc' : '%syacc%syacc%sl', \ } From 246179f9f538f7f97b141b8bfe956532de3c73c5 Mon Sep 17 00:00:00 2001 From: Kinker Wen Date: Thu, 1 Oct 2015 23:19:05 +0200 Subject: [PATCH 67/67] Remove BufAdd hook for mrufiles.vim:record() &buffertype is define after BufAdd event. Hooking record() onto BufAdd will make getbufvar(..., '&bt') return empty string even for a help buffer. --- autoload/ctrlp/mrufiles.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autoload/ctrlp/mrufiles.vim b/autoload/ctrlp/mrufiles.vim index a1821114..9a6a9786 100644 --- a/autoload/ctrlp/mrufiles.vim +++ b/autoload/ctrlp/mrufiles.vim @@ -143,7 +143,7 @@ fu! ctrlp#mrufiles#init() let s:locked = 0 aug CtrlPMRUF au! - au BufAdd,BufEnter,BufLeave,BufWritePost * cal s:record(expand('', 1)) + au BufEnter,BufLeave,BufWritePost * cal s:record(expand('', 1)) au QuickFixCmdPre *vimgrep* let s:locked = 1 au QuickFixCmdPost *vimgrep* let s:locked = 0 au VimLeavePre * cal s:savetofile(s:mergelists())