ctrlp.txt 42 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119
  1. *ctrlp.txt* Fuzzy file, buffer, mru and tag finder. v1.7.5
  2. *CtrlP* *ControlP* *'ctrlp'* *'ctrl-p'*
  3. ===============================================================================
  4. # #
  5. # :::::::: ::::::::::: ::::::::: ::: ::::::::: #
  6. # :+: :+: :+: :+: :+: :+: :+: :+: #
  7. # +:+ +:+ +:+ +:+ +:+ +:+ +:+ #
  8. # +#+ +#+ +#++:++#: +#+ +#++:++#+ #
  9. # +#+ +#+ +#+ +#+ +#+ +#+ #
  10. # #+# #+# #+# #+# #+# #+# #+# #
  11. # ######## ### ### ### ########## ### #
  12. # #
  13. ===============================================================================
  14. CONTENTS *ctrlp-contents*
  15. 1. Intro........................................|ctrlp-intro|
  16. 2. Options......................................|ctrlp-options|
  17. 3. Commands.....................................|ctrlp-commands|
  18. 4. Mappings.....................................|ctrlp-mappings|
  19. 5. Input Formats................................|ctrlp-input-formats|
  20. 6. Extensions...................................|ctrlp-extensions|
  21. ===============================================================================
  22. INTRO *ctrlp-intro*
  23. Full path fuzzy file, buffer, mru and tag finder with an intuitive interface.
  24. Written in pure Vimscript for MacVim and Vim version 7.0+. Has full support for
  25. Vim’s |regexp| as search pattern, built-in MRU files monitoring, project’s root
  26. finder, and more.
  27. To enable optional extensions (tag, dir, rtscript...), see |ctrlp-extensions|.
  28. ===============================================================================
  29. OPTIONS *ctrlp-options*
  30. Overview:~
  31. |loaded_ctrlp| Disable the plugin.
  32. |ctrlp_map| Default mapping.
  33. |ctrlp_cmd| Default command used for the default mapping.
  34. |ctrlp_by_filename| Default to filename mode or not.
  35. |ctrlp_regexp| Default to regexp mode or not.
  36. |ctrlp_match_window_bottom| Where to show the match window.
  37. |ctrlp_match_window_reversed| Sort order in the match window.
  38. |ctrlp_max_height| Max height of the match window.
  39. |ctrlp_switch_buffer| Jump to an open buffer if already opened.
  40. |ctrlp_reuse_window| Reuse special windows (help, quickfix, etc).
  41. |ctrlp_working_path_mode| How to set CtrlP’s local working directory.
  42. |ctrlp_root_markers| Additional, high priority root markers.
  43. |ctrlp_use_caching| Use per-session caching or not.
  44. |ctrlp_clear_cache_on_exit| Keep cache after exiting Vim or not.
  45. |ctrlp_cache_dir| Location of the cache directory.
  46. |ctrlp_dotfiles| Ignore dotfiles and dotdirs or not.
  47. |ctrlp_custom_ignore| Hide stuff when using |globpath()|.
  48. |ctrlp_max_files| Number of files to scan initially.
  49. |ctrlp_max_depth| Directory depth to recurse into when scanning.
  50. |ctrlp_user_command| Use an external scanner.
  51. |ctrlp_max_history| Number of entries saved in the prompt history.
  52. |ctrlp_open_new_file| How to open a file created by <c-y>.
  53. |ctrlp_open_multiple_files| How to open files selected by <c-z>.
  54. |ctrlp_arg_map| Intercept <c-y> and <c-o> or not.
  55. |ctrlp_follow_symlinks| Follow symbolic links or not.
  56. |ctrlp_lazy_update| Only update when typing has stopped.
  57. |ctrlp_default_input| Seed the prompt with an initial string.
  58. |ctrlp_use_migemo| Use Migemo patterns for Japanese filenames.
  59. |ctrlp_prompt_mappings| Change the mappings in the prompt.
  60. MRU mode:
  61. |ctrlp_mruf_max| Max MRU entries to remember.
  62. |ctrlp_mruf_exclude| Files that shouldn’t be remembered.
  63. |ctrlp_mruf_include| Files to be remembered.
  64. |ctrlp_mruf_relative| Show only MRU files in the working directory.
  65. |ctrlp_mruf_default_order| Disable sorting.
  66. |ctrlp_mruf_case_sensitive| MRU files are case sensitive or not.
  67. Advanced options:
  68. |ctrlp_status_func| Change CtrlP’s two statuslines.
  69. |ctrlp_buffer_func| Call custom functions in the CtrlP buffer.
  70. |ctrlp_match_func| Replace the built-in matching algorithm.
  71. -------------------------------------------------------------------------------
  72. Detailed descriptions and default values:~
  73. *'g:ctrlp_map'*
  74. Use this option to change the mapping to invoke CtrlP in |Normal| mode: >
  75. let g:ctrlp_map = '<c-p>'
  76. <
  77. *'g:ctrlp_cmd'*
  78. Set the default opening command to use when pressing the above mapping: >
  79. let g:ctrlp_cmd = 'CtrlP'
  80. <
  81. *'g:loaded_ctrlp'*
  82. Use this to disable the plugin completely: >
  83. let g:loaded_ctrlp = 1
  84. <
  85. *'g:ctrlp_by_filename'*
  86. Set this to 1 to set searching by filename (as opposed to full path) as the
  87. default: >
  88. let g:ctrlp_by_filename = 0
  89. <
  90. Can be toggled on/off by pressing <c-d> inside the prompt.
  91. *'g:ctrlp_regexp'*
  92. Set this to 1 to set regexp search as the default: >
  93. let g:ctrlp_regexp = 0
  94. <
  95. Can be toggled on/off by pressing <c-r> inside the prompt.
  96. *'g:ctrlp_match_window_bottom'*
  97. Set this to 0 to show the match window at the top of the screen: >
  98. let g:ctrlp_match_window_bottom = 1
  99. <
  100. *'g:ctrlp_match_window_reversed'*
  101. Change the listing order of the files in the match window. The default setting
  102. (1) is from bottom to top: >
  103. let g:ctrlp_match_window_reversed = 1
  104. <
  105. *'g:ctrlp_max_height'*
  106. Set the maximum height of the match window: >
  107. let g:ctrlp_max_height = 10
  108. <
  109. *'g:ctrlp_switch_buffer'*
  110. When opening a file with <cr> or <c-t>, if the file’s already opened somewhere
  111. CtrlP will try to jump to it instead of opening a new instance: >
  112. let g:ctrlp_switch_buffer = 2
  113. <
  114. 1 - only jump to the buffer if it’s opened in the current tab.
  115. 2 - jump tab as well if the buffer’s opened in another tab.
  116. 0 - disable this feature.
  117. *'g:ctrlp_reuse_window'*
  118. When opening a file with <cr>, CtrlP avoids opening it in windows created by
  119. plugins, help and quickfix. Use this to setup some exceptions: >
  120. let g:ctrlp_reuse_window = 'netrw'
  121. <
  122. Acceptable values are partial name, filetype or buftype of the special buffers.
  123. Use regexp to specify the pattern.
  124. Example: >
  125. let g:ctrlp_reuse_window = 'netrw\|help\|quickfix'
  126. <
  127. *'g:ctrlp_working_path_mode'*
  128. When starting up, CtrlP sets its local working directory according to this
  129. variable: >
  130. let g:ctrlp_working_path_mode = 2
  131. <
  132. 1 - the parent directory of the current file.
  133. 2 - the nearest ancestor that contains one of these directories or files:
  134. .git/ .hg/ .svn/ .bzr/ _darcs/
  135. 0 - don’t manage working directory.
  136. Note: you can use b:ctrlp_working_path_mode (a |b:var|) to set this option on a
  137. per buffer basis.
  138. *'g:ctrlp_root_markers'*
  139. Use this to set your own root markers in addition to the default ones (.git/,
  140. .hg/, .svn/, .bzr/, and _darcs/). Your markers will take precedence: >
  141. let g:ctrlp_root_markers = ['']
  142. <
  143. *'g:ctrlp_use_caching'*
  144. Set this to 0 to disable per-session caching. When disabled, caching will still
  145. be enabled for directories that have more than 4000 files: >
  146. let g:ctrlp_use_caching = 1
  147. <
  148. Note: you can quickly purge the cache by pressing <F5> while inside CtrlP.
  149. *'g:ctrlp_clear_cache_on_exit'*
  150. Set this to 0 to enable cross-session caching by not deleting the cache files
  151. upon exiting Vim: >
  152. let g:ctrlp_clear_cache_on_exit = 1
  153. <
  154. *'g:ctrlp_cache_dir'*
  155. Set the directory to store the cache files: >
  156. let g:ctrlp_cache_dir = $HOME.'/.cache/ctrlp'
  157. <
  158. *'g:ctrlp_dotfiles'*
  159. Set this to 0 if you don’t want CtrlP to scan for dotfiles and dotdirs: >
  160. let g:ctrlp_dotfiles = 1
  161. <
  162. You can use |'wildignore'| to exclude anything from the search.
  163. Examples: >
  164. " Excluding version control directories
  165. set wildignore+=*/.git/*,*/.hg/*,*/.svn/* " Linux/MacOSX
  166. set wildignore+=.git\*,.hg\*,.svn\* " Windows
  167. <
  168. Note #1: the `*/` in front of each directory glob is required.
  169. Note #2: |wildignore| influences the result of |expand()|, |globpath()| and
  170. |glob()| which many plugins use to find stuff on the system (e.g. VCS related
  171. plugins look for .git/, .hg/,... some other plugins look for external *.exe
  172. tools on Windows). So be a little mindful of what you put in your |wildignore|.
  173. *'g:ctrlp_custom_ignore'*
  174. In addition to |'wildignore'|, use this for files and directories you want only
  175. CtrlP to not show. Use regexp to specify the patterns: >
  176. let g:ctrlp_custom_ignore = ''
  177. <
  178. Examples: >
  179. let g:ctrlp_custom_ignore = '\.git$\|\.hg$\|\.svn$'
  180. let g:ctrlp_custom_ignore = {
  181. \ 'dir': '\.git$\|\.hg$\|\.svn$',
  182. \ 'file': '\.exe$\|\.so$\|\.dll$',
  183. \ 'link': 'SOME_BAD_SYMBOLIC_LINKS',
  184. \ }
  185. <
  186. Note: ignoring only works when |globpath()| is used to scan for files.
  187. *'g:ctrlp_max_files'*
  188. The maximum number of files to scan, set to 0 for no limit: >
  189. let g:ctrlp_max_files = 10000
  190. <
  191. *'g:ctrlp_max_depth'*
  192. The maximum depth of a directory tree to recurse into: >
  193. let g:ctrlp_max_depth = 40
  194. <
  195. Note: the larger these values, the more memory Vim uses.
  196. *'g:ctrlp_user_command'*
  197. Specify an external tool to use for listing files instead of using Vim’s
  198. |globpath()|. Use %s in place of the target directory: >
  199. let g:ctrlp_user_command = ''
  200. <
  201. Examples: >
  202. let g:ctrlp_user_command = 'find %s -type f' " MacOSX/Linux
  203. let g:ctrlp_user_command = 'dir %s /-n /b /s /a-d' " Windows
  204. <
  205. You can also use 'grep', 'findstr' or something else to filter the results.
  206. Examples: >
  207. let g:ctrlp_user_command = 'find %s -type f | grep (?!tmp/.*)'
  208. let g:ctrlp_user_command = 'dir %s /-n /b /s /a-d | findstr .*\.py$'
  209. <
  210. Use a version control listing command when inside a repository, this is faster
  211. when scanning large projects: >
  212. let g:ctrlp_user_command = [root_marker, listing_command, fallback_command]
  213. let g:ctrlp_user_command = {
  214. \ 'types': {
  215. \ 1: [root_marker_1, listing_command_1],
  216. \ n: [root_marker_n, listing_command_n],
  217. \ },
  218. \ 'fallback': fallback_command
  219. \ }
  220. <
  221. Examples: >
  222. let g:ctrlp_user_command = ['.git/', 'cd %s && git ls-files']
  223. let g:ctrlp_user_command = ['.hg/', 'hg --cwd %s locate -I .']
  224. let g:ctrlp_user_command = {
  225. \ 'types': {
  226. \ 1: ['.git/', 'cd %s && git ls-files'],
  227. \ 2: ['.hg/', 'hg --cwd %s locate -I .'],
  228. \ },
  229. \ 'fallback': 'find %s -type f'
  230. \ }
  231. <
  232. If the fallback_command is empty or not defined, |globpath()| will then be used
  233. when searching outside a repo.
  234. *'g:ctrlp_max_history'*
  235. The maximum number of input strings you want CtrlP to remember. The default
  236. value mirrors Vim’s global |'history'| option: >
  237. let g:ctrlp_max_history = &history
  238. <
  239. Set to 0 to disable prompt’s history. Browse the history with <c-n> and <c-p>.
  240. *'g:ctrlp_open_new_file'*
  241. Use this option to specify how the newly created file is to be opened when
  242. pressing <c-y>:
  243. t - in a new tab
  244. h - in a new horizontal split
  245. v - in a new vertical split
  246. r - in the current window
  247. >
  248. let g:ctrlp_open_new_file = 'v'
  249. <
  250. *'g:ctrlp_open_multiple_files'*
  251. If non-zero, this will enable opening multiple files with <c-z> and <c-o>: >
  252. let g:ctrlp_open_multiple_files = 'v'
  253. <
  254. Example: >
  255. let g:ctrlp_open_multiple_files = '2vr'
  256. <
  257. For the number:
  258. - If given, it’ll be used as the maximum number of windows or tabs to create
  259. when opening the files (the rest will be opened as hidden buffers).
  260. - If not given, <c-o> will open all files, each in a new window or new tab.
  261. For the letters:
  262. t - each file in a new tab.
  263. h - each file in a new horizontal split.
  264. v - each file in a new vertical split.
  265. Reuse the current window:
  266. tr,
  267. hr,
  268. vr - open the first file in the current window, then the remaining files in
  269. new splits or new tabs just like with t, h, v.
  270. *'g:ctrlp_arg_map'*
  271. When this is set to 1, the <c-o> and <c-y> mappings will accept one extra key
  272. as an argument to override their default behavior: >
  273. let g:ctrlp_arg_map = 0
  274. <
  275. Pressing <c-o> or <c-y> will then prompt for a keypress. The key can be:
  276. t - open in tab(s)
  277. h - open in horizontal split(s)
  278. v - open in vertical split(s)
  279. r - open in current window (for <c-y> only)
  280. <esc>, <c-c> - cancel and go back to the prompt.
  281. Any other key - use the behavior specified with |g:ctrlp_open_new_file| and
  282. |g:ctrlp_open_multiple_files|.
  283. *'g:ctrlp_follow_symlinks'*
  284. Set this to 1 to follow symbolic links when listing files: >
  285. let g:ctrlp_follow_symlinks = 0
  286. <
  287. When enabled, looped internal symlinks will be ignored to avoid duplicates.
  288. *'g:ctrlp_lazy_update'*
  289. Set this to 1 to enable the lazy-update feature: only update the match window
  290. after typing’s been stopped for a certain amount of time: >
  291. let g:ctrlp_lazy_update = 0
  292. <
  293. If is 1, update after 250ms. If bigger than 1, the number will be used as the
  294. delay time in milliseconds.
  295. *'g:ctrlp_default_input'*
  296. Set this to 1 to enable seeding the prompt with the current file’s relative
  297. path: >
  298. let g:ctrlp_default_input = 0
  299. <
  300. *'g:ctrlp_use_migemo'*
  301. Set this to 1 to use Migemo Pattern for Japanese filenames. Migemo Search only
  302. works in regexp mode. To split the pattern, separate words with space: >
  303. let g:ctrlp_use_migemo = 0
  304. <
  305. *'g:ctrlp_prompt_mappings'*
  306. Use this to customize the mappings inside CtrlP’s prompt to your liking. You
  307. only need to keep the lines that you’ve changed the values (inside []): >
  308. let g:ctrlp_prompt_mappings = {
  309. \ 'PrtBS()': ['<bs>', '<c-]>'],
  310. \ 'PrtDelete()': ['<del>'],
  311. \ 'PrtDeleteWord()': ['<c-w>'],
  312. \ 'PrtClear()': ['<c-u>'],
  313. \ 'PrtSelectMove("j")': ['<c-j>', '<down>'],
  314. \ 'PrtSelectMove("k")': ['<c-k>', '<up>'],
  315. \ 'PrtSelectMove("t")': ['<Home>', '<kHome>'],
  316. \ 'PrtSelectMove("b")': ['<End>', '<kEnd>'],
  317. \ 'PrtSelectMove("u")': ['<PageUp>', '<kPageUp>'],
  318. \ 'PrtSelectMove("d")': ['<PageDown>', '<kPageDown>'],
  319. \ 'PrtHistory(-1)': ['<c-n>'],
  320. \ 'PrtHistory(1)': ['<c-p>'],
  321. \ 'AcceptSelection("e")': ['<cr>', '<2-LeftMouse>'],
  322. \ 'AcceptSelection("h")': ['<c-x>', '<c-cr>', '<c-s>'],
  323. \ 'AcceptSelection("t")': ['<c-t>'],
  324. \ 'AcceptSelection("v")': ['<c-v>', '<RightMouse>'],
  325. \ 'ToggleFocus()': ['<s-tab>'],
  326. \ 'ToggleRegex()': ['<c-r>'],
  327. \ 'ToggleByFname()': ['<c-d>'],
  328. \ 'ToggleType(1)': ['<c-f>', '<c-up>'],
  329. \ 'ToggleType(-1)': ['<c-b>', '<c-down>'],
  330. \ 'PrtExpandDir()': ['<tab>'],
  331. \ 'PrtInsert("w")': ['<F2>', '<insert>'],
  332. \ 'PrtInsert("s")': ['<F3>'],
  333. \ 'PrtInsert("v")': ['<F4>'],
  334. \ 'PrtInsert("+")': ['<F6>', '<MiddleMouse>'],
  335. \ 'PrtCurStart()': ['<c-a>'],
  336. \ 'PrtCurEnd()': ['<c-e>'],
  337. \ 'PrtCurLeft()': ['<c-h>', '<left>', '<c-^>'],
  338. \ 'PrtCurRight()': ['<c-l>', '<right>'],
  339. \ 'PrtClearCache()': ['<F5>'],
  340. \ 'PrtDeleteEnt()': ['<F7>'],
  341. \ 'CreateNewFile()': ['<c-y>'],
  342. \ 'MarkToOpen()': ['<c-z>'],
  343. \ 'OpenMulti()': ['<c-o>'],
  344. \ 'PrtExit()': ['<esc>', '<c-c>', '<c-g>'],
  345. \ }
  346. <
  347. Note: In some terminals, it’s not possible to remap <c-h> without also changing
  348. <bs> (|keycodes|). So if pressing <bs> moves the cursor to the left instead of
  349. deleting a char for you, add this to your |.vimrc| to disable the plugin’s
  350. default <c-h> mapping: >
  351. let g:ctrlp_prompt_mappings = { 'PrtCurLeft()': ['<left>', '<c-^>'] }
  352. <
  353. ----------------------------------------
  354. MRU mode options:~
  355. *'g:ctrlp_mruf_max'*
  356. Specify the number of recently opened files you want CtrlP to remember: >
  357. let g:ctrlp_mruf_max = 250
  358. <
  359. *'g:ctrlp_mruf_exclude'*
  360. Files you don’t want CtrlP to remember. Use regexp to specify the patterns: >
  361. let g:ctrlp_mruf_exclude = ''
  362. <
  363. Examples: >
  364. let g:ctrlp_mruf_exclude = '/tmp/.*\|/temp/.*' " MacOSX/Linux
  365. let g:ctrlp_mruf_exclude = '^C:\\dev\\tmp\\.*' " Windows
  366. <
  367. *'g:ctrlp_mruf_include'*
  368. And if you want CtrlP to only remember some files, specify them here: >
  369. let g:ctrlp_mruf_include = ''
  370. <
  371. Example: >
  372. let g:ctrlp_mruf_include = '\.py$\|\.rb$'
  373. <
  374. *'g:ctrlp_mruf_relative'*
  375. Set this to 1 to show only MRU files in the current working directory: >
  376. let g:ctrlp_mruf_relative = 0
  377. <
  378. *'g:ctrlp_mruf_default_order'*
  379. Set this to 1 to disable sorting when searching in MRU mode: >
  380. let g:ctrlp_mruf_default_order = 0
  381. <
  382. *'g:ctrlp_mruf_case_sensitive'*
  383. Match this with your file system case-sensitivity setting to avoid duplicate
  384. MRU entries: >
  385. let g:ctrlp_mruf_case_sensitive = 1
  386. <
  387. ----------------------------------------
  388. Advanced options:~
  389. *'g:ctrlp_status_func'*
  390. Use this to customize the statuslines for the CtrlP window: >
  391. let g:ctrlp_status_func = {}
  392. <
  393. Example: >
  394. let g:ctrlp_status_func = {
  395. \ 'main': 'Function_Name_1',
  396. \ 'prog': 'Function_Name_2',
  397. \ }
  398. <
  399. Structure of the functions: >
  400. " Main statusline
  401. function! Function_Name_1(focus, byfname, regex, prev, item, next, marked)
  402. " Arguments:
  403. " |
  404. " +- a:focus : The focus of the prompt: "prt" or "win".
  405. " |
  406. " +- a:byfname : In filename mode or in full path mode: "file" or "path".
  407. " |
  408. " +- a:regex : In regex mode: 1 or 0.
  409. " |
  410. " +- a:prev : The previous search mode.
  411. " |
  412. " +- a:item : The current search mode.
  413. " |
  414. " +- a:next : The next search mode.
  415. " |
  416. " +- a:marked : The number of marked files, or a comma separated list of
  417. " the filenames.
  418. return full_statusline
  419. endfunction
  420. " Progress statusline
  421. function! Function_Name_2(str)
  422. " a:str : Either the number of files scanned so far, or a string indicating
  423. " the current directory is being scanned with a user_command.
  424. return full_statusline
  425. endfunction
  426. <
  427. See https://gist.github.com/1610859 for a working example.
  428. *'g:ctrlp_buffer_func'*
  429. Specify the functions that will be called after entering and before exiting the
  430. CtrlP buffer: >
  431. let g:ctrlp_buffer_func = {}
  432. <
  433. Example: >
  434. let g:ctrlp_buffer_func = {
  435. \ 'enter': 'Function_Name_1',
  436. \ 'exit': 'Function_Name_2',
  437. \ }
  438. <
  439. *'g:ctrlp_match_func'*
  440. Set an external fuzzy matching function for CtrlP to use: >
  441. let g:ctrlp_match_func = {}
  442. <
  443. Example: >
  444. let g:ctrlp_match_func = { 'match': 'Function_Name' }
  445. <
  446. Structure of the function: >
  447. function! Function_Name(items, str, limit, mmode, ispath, crfile, regex)
  448. " Arguments:
  449. " |
  450. " +- a:items : The full list of items to search in.
  451. " |
  452. " +- a:str : The string entered by the user.
  453. " |
  454. " +- a:limit : The max height of the match window. Can be used to limit
  455. " | the number of items to return.
  456. " |
  457. " +- a:mmode : The match mode. Can be one of these strings:
  458. " | + "full-line": match the entire line.
  459. " | + "filename-only": match only the filename.
  460. " | + "first-non-tab": match until the first tab char.
  461. " | + "until-last-tab": match until the last tab char.
  462. " |
  463. " +- a:ispath : Is 1 when searching in file, buffer, mru, dir, and rtscript
  464. " | modes. Is 0 otherwise.
  465. " |
  466. " +- a:crfile : The file in the current window. Should be excluded from the
  467. " | results when a:ispath == 1.
  468. " |
  469. " +- a:regex : In regex mode: 1 or 0.
  470. return list_of_matched_items
  471. endfunction
  472. <
  473. ===============================================================================
  474. COMMANDS *ctrlp-commands*
  475. *:CtrlP*
  476. :CtrlP [starting-directory]
  477. Open CtrlP in find file mode.
  478. If no argument is given, the value of |g:ctrlp_working_path_mode| will be
  479. used to determine the starting directory.
  480. You can use <tab> to auto-complete the [starting-directory] when typing it.
  481. *:CtrlPBuffer*
  482. :CtrlPBuffer
  483. Open CtrlP in find buffer mode.
  484. *:CtrlPMRU*
  485. :CtrlPMRU
  486. Open CtrlP in find Most-Recently-Used file mode.
  487. *:CtrlPLastMode*
  488. :CtrlPLastMode
  489. Open CtrlP in the last mode used.
  490. *:CtrlPRoot*
  491. :CtrlPRoot
  492. This acts like |:CtrlP| with |g:ctrlp_working_path_mode| = 2 (ignores its
  493. current value).
  494. *:CtrlPClearCache*
  495. :CtrlPClearCache
  496. Flush the cache for the current working directory. The same as pressing <F5>
  497. inside CtrlP.
  498. To enable or disable caching, use the |g:ctrlp_use_caching| option.
  499. *:CtrlPClearAllCaches*
  500. :CtrlPClearAllCaches
  501. Delete all the cache files saved in |g:ctrlp_cache_dir|.
  502. *:CtrlPReload*
  503. :CtrlPReload
  504. Load new values for the option variables.
  505. -------------------------------------------------------------------------------
  506. For commands provided by bundled extensions, see |ctrlp-extensions|.
  507. ===============================================================================
  508. MAPPINGS *ctrlp-mappings*
  509. *'ctrlp-<c-p>'*
  510. <c-p>
  511. Default |Normal| mode mapping to open the CtrlP prompt in find file mode.
  512. Once inside the prompt:~
  513. <c-d>
  514. Toggle between full-path search and filename only search.
  515. Note: in filename mode, the prompt’s base is '>d>' instead of '>>>'
  516. <c-r> *'ctrlp-fullregexp'*
  517. Toggle between the string mode and full regexp mode.
  518. Note: in full regexp mode, the prompt’s base is 'r>>' instead of '>>>'
  519. See also |input-formats| (guide) and |g:ctrlp_regexp_search| (option).
  520. <c-f>, 'forward'
  521. <c-up>
  522. Scroll to the 'next' search mode in the sequence.
  523. <c-b>, 'backward'
  524. <c-down>
  525. Scroll to the 'previous' search mode in the sequence.
  526. <tab>
  527. Auto-complete directory names under the current working directory inside
  528. the prompt.
  529. <s-tab>
  530. Toggle the focus between the match window and the prompt.
  531. <c-j>,
  532. <down>
  533. Move selection down.
  534. <c-k>,
  535. <up>
  536. Move selection up.
  537. <c-a>
  538. Move the cursor to the 'start' of the prompt.
  539. <c-e>
  540. Move the cursor to the 'end' of the prompt.
  541. <c-h>,
  542. <left>,
  543. <c-^>
  544. Move the cursor one character to the 'left'.
  545. <c-l>,
  546. <right>
  547. Move the cursor one character to the 'right'.
  548. <c-]>,
  549. <bs>
  550. Delete the preceding character.
  551. <del>
  552. Delete the current character.
  553. <c-w>
  554. Delete a preceding inner word.
  555. <c-u>
  556. Clear the input field.
  557. <cr>
  558. Open selected file in the active window if possible.
  559. <c-t>
  560. Open selected file in a new 'tab' after the last tabpage.
  561. <c-v>
  562. Open selected file in a 'vertical' split.
  563. <c-x>,
  564. <c-cr>,
  565. <c-s>
  566. Open selected file in a 'horizontal' split.
  567. <c-y>
  568. Create a new file and its parent directories.
  569. <c-n>
  570. Next string in the prompt’s history.
  571. <c-p>
  572. Previous string in the prompt’s history.
  573. <c-z>
  574. - Mark/unmark a file to be opened with <c-o>.
  575. - Or mark/unmark a file to create a new file in its directory using <c-y>.
  576. <c-o>
  577. Open files marked by <c-z>.
  578. <F5>
  579. - Refresh the match window and purge the cache for the current directory.
  580. - Or remove deleted files from the MRU list.
  581. <F7>
  582. - Wipe the MRU list.
  583. - Or delete MRU entries marked by <c-z>.
  584. <insert>
  585. Insert the word under the cursor (in the current buffer) into the prompt.
  586. <esc>,
  587. <c-c>,
  588. <c-g>
  589. Exit CtrlP.
  590. Note: <c-c> can also be used to stop the scan if it’s taking too long.
  591. Choose your own mappings with |g:ctrlp_prompt_mappings|.
  592. When inside the match window (press <s-tab> to switch):~
  593. a-z
  594. 0-9
  595. ~^-=;`',.+!@#$%&_(){}[]
  596. Cycle through the lines with the first letter (of paths or filenames) that
  597. matches that key.
  598. ===============================================================================
  599. INPUT FORMATS *ctrlp-input-formats*
  600. Formats for inputting in the prompt:~
  601. a) Simple string.
  602. E.g. 'abc' is understood internally as 'a[^a]\{-}b[^b]\{-}c'
  603. b) When in regexp mode, the input string’s treated as a Vim’s regexp |pattern|
  604. without any modification.
  605. E.g. 'abc\d*efg' will be read as 'abc\d*efg'.
  606. See |ctrlp-fullregexp| (keymap) and |g:ctrlp_regexp_search| (option) for
  607. how to enable regexp mode.
  608. c) End the string with a colon ':' followed by a Vim command to execute that
  609. command after opening the file. If you need to use ':' literally, escape it
  610. with a backslash: '\:'. When opening multiple files, the command will be
  611. executed on each opening file.
  612. E.g. 'abc:45' will open the selected file and jump to line 45.
  613. 'abc:/any\:string' will open the selected file and jump to the first
  614. instance of 'any:string'.
  615. 'abc:+setf\ myfiletype|50' will open the selected file and set its
  616. filetype to 'myfiletype', then jump to line 50.
  617. 'abc:diffthis' will open the selected files and run |:diffthis| on the
  618. first 4 files (if marked).
  619. See also Vim’s |++opt| and |+cmd|.
  620. d) Type exactly two dots '..' at the start of the prompt and press enter to go
  621. backward in the directory tree by 1 level. If the parent directory is
  622. large, this might be slow.
  623. e) Similarly, submit '/' or '\' to find and go to the project’s root. If the
  624. project is large, using a VCS listing command to look for files might help
  625. speeding up the intial scan (see |g:ctrlp_user_command| for more details).
  626. Note: e) and d) only work in find file mode and directory mode.
  627. f) Type the name of a non-existent file and press <c-y> to create it. Mark a
  628. file with <c-z> to create the new file in the same directory as the marked
  629. file.
  630. E.g. 'parentdir/newfile.txt' will create a directory named 'parentdir' as
  631. well as 'newfile.txt'.
  632. If 'some/old/dirs/oldfile.txt' is marked with <c-z>, then 'parentdir'
  633. and 'newfile.txt' will be created in 'some/old/dirs'. The final path
  634. will then be 'some/old/dirs/parentdir/newfile.txt'.
  635. Use '\' in place of '/' on Windows (if |'ssl'| is not set).
  636. g) Submit ? to open this help file.
  637. ===============================================================================
  638. EXTENSIONS *ctrlp-extensions*
  639. Extensions are optional. To enable an extension, add its name to the variable
  640. g:ctrlp_extensions: >
  641. let g:ctrlp_extensions = ['tag', 'buffertag', 'quickfix', 'dir', 'rtscript',
  642. \ 'undo', 'line', 'changes', 'mixed', 'bookmarkdir']
  643. <
  644. The order of the items will be the order they appear on the statusline and when
  645. using <c-f>, <c-b>.
  646. Available extensions:~
  647. *:CtrlPTag*
  648. * Tag mode:~
  649. - Name: 'tag'
  650. - Command: ':CtrlPTag'
  651. - Search for a tag within a generated central tags file, and jump to the
  652. definition. Use the Vim’s option |'tags'| to specify the names and the
  653. locations of the tags file(s).
  654. E.g. set tags+=doc/tags
  655. *:CtrlPBufTag*
  656. *:CtrlPBufTagAll*
  657. * Buffer Tag mode:~
  658. - Name: 'buffertag'
  659. - Commands: ':CtrlPBufTag [buffer]',
  660. ':CtrlPBufTagAll'.
  661. - Search for a tag within the current buffer or all listed buffers and jump
  662. to the definition. Requires |exuberant_ctags| or compatible programs.
  663. *:CtrlPQuickfix*
  664. * Quickfix mode:~
  665. - Name: 'quickfix'
  666. - Command: ':CtrlPQuickfix'
  667. - Search for an entry in the current quickfix errors and jump to it.
  668. *:CtrlPDir*
  669. * Directory mode:~
  670. - Name: 'dir'
  671. - Command: ':CtrlPDir [starting-directory]'
  672. - Search for a directory and change the working directory to it.
  673. - Mappings:
  674. + <cr> change the local working directory for CtrlP and keep it open.
  675. + <c-t> change the global working directory (exit).
  676. + <c-v> change the local working directory for the current window (exit).
  677. + <c-x> change the global working directory to CtrlP’s current local
  678. working directory (exit).
  679. *:CtrlPRTS*
  680. * Runtime script mode:~
  681. - Name: 'rtscript'
  682. - Command: ':CtrlPRTS'
  683. - Search for files (vimscripts, docs, snippets...) in runtimepath.
  684. *:CtrlPUndo*
  685. * Undo mode:~
  686. - Name: 'undo'
  687. - Command: ':CtrlPUndo'
  688. - Browse undo history.
  689. *:CtrlPLine*
  690. * Line mode:~
  691. - Name: 'line'
  692. - Command: ':CtrlPLine'
  693. - Search for a line in all listed buffers.
  694. *:CtrlPChange*
  695. *:CtrlPChangeAll*
  696. * Change list mode:~
  697. - Name: 'changes'
  698. - Commands: ':CtrlPChange [buffer]',
  699. ':CtrlPChangeAll'.
  700. - Search for and jump to a recent change in the current buffer or in all
  701. listed buffers.
  702. *:CtrlPMixed*
  703. * Mixed mode:~
  704. - Name: 'mixed'
  705. - Command: ':CtrlPMixed'
  706. - Search in files, buffers and MRU files at the same time.
  707. *:CtrlPBookmarkDir*
  708. *:CtrlPBookmarkDirAdd*
  709. * BookmarkDir mode:~
  710. - Name: 'bookmarkdir'
  711. - Commands: ':CtrlPBookmarkDir',
  712. ':CtrlPBookmarkDirAdd [directory]'.
  713. - Search for a bookmarked directory and change the working directory to it.
  714. - Mappings:
  715. + <cr> change the local working directory for CtrlP, keep it open and
  716. switch to find file mode.
  717. + <c-x> change the global working directory (exit).
  718. + <c-v> change the local working directory for the current window (exit).
  719. + <F7>
  720. - Wipe bookmark list.
  721. - Or delete entries marked by <c-z>.
  722. ----------------------------------------
  723. Buffer Tag mode options:~
  724. *'g:ctrlp_buftag_ctags_bin'*
  725. If ctags isn’t in your $PATH, use this to set its location: >
  726. let g:ctrlp_buftag_ctags_bin = ''
  727. <
  728. *'g:ctrlp_buftag_systemenc'*
  729. Match this with your OS’s encoding (not Vim’s). The default value mirrors Vim’s
  730. global |'encoding'| option: >
  731. let g:ctrlp_buftag_systemenc = &encoding
  732. <
  733. *'g:ctrlp_buftag_types'*
  734. Use this to set the arguments for ctags, jsctags... for a given filetype: >
  735. let g:ctrlp_buftag_types = ''
  736. <
  737. Examples: >
  738. let g:ctrlp_buftag_types = {
  739. \ 'erlang' : '--language-force=erlang --erlang-types=drmf',
  740. \ 'javascript' : {
  741. \ 'bin': 'jsctags',
  742. \ 'args': '-f -',
  743. \ },
  744. \ }
  745. <
  746. ===============================================================================
  747. CUSTOMIZATION *ctrlp-customization*
  748. Highlighting:~
  749. * For the CtrlP buffer:
  750. CtrlPNoEntries : the message when no match is found (Error)
  751. CtrlPMatch : the matched pattern (Identifier)
  752. CtrlPLinePre : the line prefix '>' in the match window
  753. CtrlPPrtBase : the prompt’s base (Comment)
  754. CtrlPPrtText : the prompt’s text (|hl-Normal|)
  755. CtrlPPrtCursor : the prompt’s cursor when moving over the text (Constant)
  756. * In extensions:
  757. CtrlPTabExtra : the part of each line that’s not matched against (Comment)
  758. CtrlPBufName : the buffer name an entry belongs to (|hl-Directory|)
  759. CtrlPTagKind : the kind of the tag in buffer-tag mode (|hl-Title|)
  760. CtrlPqfLineCol : the line and column numbers in quickfix mode (Comment)
  761. CtrlPUndoT : the elapsed time in undo mode (|hl-Directory|)
  762. CtrlPUndoBr : the square brackets [] in undo mode (Comment)
  763. CtrlPUndoNr : the undo number inside [] in undo mode (String)
  764. CtrlPUndoSv : the point where the file was saved (Comment)
  765. CtrlPUndoPo : the current position in the undo tree (|hl-Title|)
  766. CtrlPBookmark : the name of the bookmark (Identifier)
  767. Statuslines:~
  768. * Highlight groups:
  769. CtrlPMode1 : 'prt' or 'win', also for 'regex' (Character)
  770. CtrlPMode2 : 'file' or 'path', also for the local working dir (|hl-LineNr|)
  771. CtrlPStats : the scanning status (Function)
  772. For rebuilding the statuslines, see |g:ctrlp_status_func|.
  773. ===============================================================================
  774. MISCELLANEOUS CONFIGS *ctrlp-miscellaneous-configs*
  775. * Use |wildignore| for |g:ctrlp_user_command|:
  776. >
  777. function! s:wig2cmd()
  778. " Change wildignore into space or | separated groups
  779. " e.g. .aux .out .toc .jpg .bmp .gif
  780. " or .aux$\|.out$\|.toc$\|.jpg$\|.bmp$\|.gif$
  781. let pats = ['[*\/]*\([?_.0-9A-Za-z]\+\)\([*\/]*\)\(\\\@<!,\|$\)','\\\@<!,']
  782. let subs = has('win32') || has('win64') ? ['\1\3', ' '] : ['\1\2\3', '\\|']
  783. let expr = substitute(&wig, pats[0], subs[0], 'g')
  784. let expr = substitute(expr, pats[1], subs[1], 'g')
  785. let expr = substitute(expr, '\\,', ',', 'g')
  786. " Set the user_command option
  787. let g:ctrlp_user_command = has('win32') || has('win64')
  788. \ ? 'dir %s /-n /b /s /a-d | findstr /V /l "'.expr.'"'
  789. \ : 'find %s -type f | grep -v "'.expr .'"'
  790. endfunction
  791. call s:wig2cmd()
  792. <
  793. (submitted by Rich Alesi <github.com/ralesi>)
  794. * A standalone function to set the working directory to the project’s root, or
  795. to the parent directory of the current file if a root can’t be found:
  796. >
  797. function! s:setcwd()
  798. let cph = expand('%:p:h', 1)
  799. if match(cph, '\v^<.+>://') >= 0 | retu | en
  800. for mkr in ['.git/', '.hg/', '.svn/', '.bzr/', '_darcs/', '.vimprojects']
  801. let wd = call('find'.(mkr =~ '/$' ? 'dir' : 'file'), [mkr, cph.';'])
  802. if wd != '' | let &acd = 0 | brea | en
  803. endfo
  804. exe 'lc!' fnameescape(wd == '' ? cph : substitute(wd, mkr.'$', '.', ''))
  805. endfunction
  806. autocmd BufEnter * call s:setcwd()
  807. <
  808. (requires Vim 7.1.299+)
  809. ===============================================================================
  810. CREDITS *ctrlp-credits*
  811. Developed by Kien Nguyen <github.com/kien>.
  812. Project’s homepage: http://kien.github.com/ctrlp.vim
  813. Git repository: https://github.com/kien/ctrlp.vim
  814. Mercurial repository: https://bitbucket.org/kien/ctrlp.vim
  815. -------------------------------------------------------------------------------
  816. Thanks to everyone that has submitted ideas, bug reports or helped debugging on
  817. gibhub, bitbucket, and through email.
  818. Special thanks:~
  819. * Woojong Koh <github.com/wjkoh>
  820. * Simon Ruderich
  821. * Yasuhiro Matsumoto <github.com/mattn>
  822. * Ken Earley <github.com/kenearley>
  823. * Kyo Nagashima <github.com/hail2u>
  824. * Zak Johnson <github.com/zakj>
  825. * Diego Viola <github.com/diegoviola>
  826. * Piet Delport <github.com/pjdelport>
  827. * Thibault Duplessis <github.com/ornicar>
  828. * Kent Sibilev <github.com/datanoise>
  829. * Tacahiroy <github.com/tacahiroy>
  830. * Luca Pette <github.com/lucapette>
  831. ===============================================================================
  832. CHANGELOG *ctrlp-changelog*
  833. + New option: |g:ctrlp_mruf_default_order|
  834. + New feature: Bookmarked directories extension.
  835. + New commands: |:CtrlPBookmarkDir|
  836. |:CtrlPBookmarkDirAdd|
  837. Before 2012/04/15~
  838. + New option: |g:ctrlp_buffer_func|, callback functions for CtrlP buffer.
  839. + Remove: g:ctrlp_mruf_last_entered, make it a default for MRU mode.
  840. + New commands: |:CtrlPLastMode|, open CtrlP in the last mode used.
  841. |:CtrlPMixed|, search in files, buffers and MRU files.
  842. Before 2012/03/31~
  843. + New options: |g:ctrlp_default_input|, default input when entering CtrlP.
  844. |g:ctrlp_match_func|, allow using a custom fuzzy matcher.
  845. + Rename:
  846. *ClearCtrlPCache* -> |CtrlPClearCache|
  847. *ClearAllCtrlPCaches* -> |CtrlPClearAllCaches|
  848. *ResetCtrlP* -> |CtrlPReload|
  849. Before 2012/03/02~
  850. + Rename:
  851. *g:ctrlp_regexp_search* -> |g:ctrlp_regexp|,
  852. *g:ctrlp_dont_split* -> |g:ctrlp_reuse_window|,
  853. *g:ctrlp_jump_to_buffer* -> |g:ctrlp_switch_buffer|.
  854. + Rename and tweak:
  855. *g:ctrlp_open_multi* -> |g:ctrlp_open_multiple_files|.
  856. + Deprecate *g:ctrlp_highlight_match*
  857. + Extend |g:ctrlp_user_command| to support multiple commands.
  858. + New option: |g:ctrlp_mruf_last_entered| change MRU to Recently-Entered.
  859. Before 2012/01/15~
  860. + New mapping: Switch <tab> and <s-tab>. <tab> is now used for completion
  861. of directory names under the current working directory.
  862. + New options: |g:ctrlp_arg_map| for <c-y>, <c-o> to accept an argument.
  863. |g:ctrlp_status_func| custom statusline.
  864. |g:ctrlp_mruf_relative| show only MRU files inside cwd.
  865. + Extend g:ctrlp_open_multi with new optional values: tr, hr, vr.
  866. + Extend |g:ctrlp_custom_ignore| to specifically filter dir, file and link.
  867. Before 2012/01/05~
  868. + New feature: Buffer Tag extension.
  869. + New commands: |:CtrlPBufTag|, |:CtrlPBufTagAll|.
  870. + New options: |g:ctrlp_cmd|,
  871. |g:ctrlp_custom_ignore|
  872. Before 2011/11/30~
  873. + New features: Tag, Quickfix and Directory extensions.
  874. + New commands: |:CtrlPTag|, |:CtrlPQuickfix|, |:CtrlPDir|.
  875. + New options: |g:ctrlp_use_migemo|,
  876. |g:ctrlp_lazy_update|,
  877. |g:ctrlp_follow_symlinks|
  878. Before 2011/11/13~
  879. + New special input: '/' and '\' find root (|ctrlp-input-formats| (e))
  880. + Remove ctrlp#SetWorkingPath().
  881. + Remove *g:ctrlp_mru_files* and make MRU mode permanent.
  882. + Extend g:ctrlp_open_multi, add new ways to open files.
  883. + New option: g:ctrlp_dont_split,
  884. |g:ctrlp_mruf_case_sensitive|
  885. Before 2011/10/30~
  886. + New feature: Support for custom extensions.
  887. <F5> also removes non-existent files from MRU list.
  888. + New option: g:ctrlp_jump_to_buffer
  889. Before 2011/10/12~
  890. + New features: Open multiple files.
  891. Pass Vim’s |++opt| and |+cmd| to the opening file
  892. (|ctrlp-input-formats| (c))
  893. Auto-complete each dir for |:CtrlP| [starting-directory]
  894. + New mappings: <c-z> mark/unmark a file to be opened with <c-o>.
  895. <c-o> open all marked files.
  896. + New option: g:ctrlp_open_multi
  897. + Remove *g:ctrlp_persistent_input* *g:ctrlp_live_update* and <c-^>.
  898. Before 2011/09/29~
  899. + New mappings: <c-n>, <c-p> next/prev string in the input history.
  900. <c-y> create a new file and its parent dirs.
  901. + New options: |g:ctrlp_open_new_file|,
  902. |g:ctrlp_max_history|
  903. + Added a new open-in-horizontal-split mapping: <c-x>
  904. Before 2011/09/19~
  905. + New command: ResetCtrlP
  906. + New options: |g:ctrlp_max_files|,
  907. |g:ctrlp_max_depth|,
  908. g:ctrlp_live_update
  909. + New mapping: <c-^>
  910. Before 2011/09/12~
  911. + Ability to cycle through matched lines in the match window.
  912. + Extend the behavior of g:ctrlp_persistent_input
  913. + Extend the behavior of |:CtrlP|
  914. + New options: |g:ctrlp_dotfiles|,
  915. |g:ctrlp_clear_cache_on_exit|,
  916. g:ctrlp_highlight_match,
  917. |g:ctrlp_user_command|
  918. + New special input: '..' (|ctrlp-input-formats| (d))
  919. + New mapping: <F5>.
  920. + New commands: |:CtrlPCurWD|,
  921. |:CtrlPCurFile|,
  922. |:CtrlPRoot|
  923. + New feature: Search in most recently used (MRU) files
  924. + New mapping: <c-b>.
  925. + Extended the behavior of <c-f>.
  926. + New options: g:ctrlp_mru_files,
  927. |g:ctrlp_mruf_max|,
  928. |g:ctrlp_mruf_exclude|,
  929. |g:ctrlp_mruf_include|
  930. + New command: |:CtrlPMRU|
  931. First public release: 2011/09/06~
  932. ===============================================================================
  933. vim:ft=help:et:ts=2:sw=2:sts=2:norl