ctrlp.vim/doc/ctrlp.txt

563 lines
21 KiB
Plaintext
Raw Normal View History

*ctrlp.txt* Full path fuzzy file, buffer and MRU file finder. v1.5.8
2011-08-21 22:14:00 -04:00
*CtrlP* *ControlP* *'ctrlp'* *'ctrl-p'*
===============================================================================
# #
# :::::::: ::::::::::: ::::::::: ::: ::::::::: #
# :+: :+: :+: :+: :+: :+: :+: :+: #
# +:+ +:+ +:+ +:+ +:+ +:+ +:+ #
# +#+ +#+ +#++:++#: +#+ +#++:++#+ #
# +#+ +#+ +#+ +#+ +#+ +#+ #
# #+# #+# #+# #+# #+# #+# #+# #
# ######## ### ### ### ########## ### #
# #
===============================================================================
CONTENTS *ctrlp-contents*
2011-11-02 19:09:12 -04:00
1. Intro........................................|ctrlp-intro|
2. Options......................................|ctrlp-options|
3. Commands.....................................|ctrlp-commands|
4. Mappings.....................................|ctrlp-mappings|
5. Input Formats................................|ctrlp-input-formats|
2011-08-21 22:14:00 -04:00
===============================================================================
1. Intro *ctrlp-intro*
2011-09-07 11:10:52 -04:00
Full path fuzzy file, buffer and MRU file finder with an intuitive interface.
Written in pure Vimscript for MacVim and Vim version 7.0+. Has full support for
Vims |regexp| as search pattern, built-in MRU monitoring, projects root
finder, and more.
2011-08-21 22:14:00 -04:00
===============================================================================
2. Options *ctrlp-options*
Below are the available options and their default values.
*'g:ctrlp_map'*
Use this option to change the mapping to invoke |CtrlP| in |Normal| mode: >
let g:ctrlp_map = '<c-p>'
<
*'g:loaded_ctrlp'*
Use this option to disable the plugin completely: >
let g:loaded_ctrlp = 1
<
2011-09-11 12:53:32 -04:00
*'g:ctrlp_by_filename'*
Set this to 1 to set search by filename (not full path) as the default: >
let g:ctrlp_by_filename = 0
<
*'g:ctrlp_regexp_search'*
2011-11-02 19:09:12 -04:00
Set this to 1 to set |regexp| search as the default mode: >
2011-09-11 12:53:32 -04:00
let g:ctrlp_regexp_search = 0
<
*'g:ctrlp_match_window_bottom'*
Set this to 0 to show the match window at the top of the screen: >
let g:ctrlp_match_window_bottom = 1
<
2011-08-21 22:14:00 -04:00
*'g:ctrlp_match_window_reversed'*
Reverse the sort order of the matched files in the match window. The default
setting is from bottom to top: >
let g:ctrlp_match_window_reversed = 1
<
*'g:ctrlp_max_height'*
Set the maximum height of the match window: >
let g:ctrlp_max_height = 10
<
*'g:ctrlp_jump_to_buffer'*
Set this to 0 to disable the jump-to-open-buffer feature; set to 2 to also jump
tab if the selected buffers opened in another tab: >
let g:ctrlp_jump_to_buffer = 1
<
2011-08-21 22:14:00 -04:00
*'g:ctrlp_working_path_mode'*
*SetWorkingPath()*
When starting up the prompt, temporarily set the working directory (i.e. the
2011-08-21 22:14:00 -04:00
|current-directory|) to:
1 - the parent directory of the current file.
2 - the nearest ancestor that contains one of these directories/files:
.git/
.hg/
.bzr/
_darcs/
root.dir
.vimprojects
0 - dont manage working directory.
>
let g:ctrlp_working_path_mode = 2
2011-08-21 22:14:00 -04:00
<
You can use this functionality outside of |CtrlP| by adding the following line
2011-11-02 19:09:12 -04:00
to your |.vimrc|; the parameter is the same (1, 2 or 0): >
2011-08-21 22:14:00 -04:00
au BufEnter * cal ctrlp#SetWorkingPath(2)
<
2011-09-06 09:03:31 -04:00
*'g:ctrlp_root_markers'*
Use this to set your own root markers for the |SetWorkingPath()| function, in
addition to the default ones. Your markers will take precedence: >
2011-09-06 09:03:31 -04:00
let g:ctrlp_root_markers = ['']
<
2011-09-10 08:51:49 -04:00
*'g:ctrlp_use_caching'*
2011-09-10 14:54:07 -04:00
Set this to 0 to disable per-session caching. When disabled, caching will still
be enabled for directories that have more than 4000 files: >
2011-09-10 08:51:49 -04:00
let g:ctrlp_use_caching = 1
<
Note: you can quickly purge the cache by pressing <F5> while inside |CtrlP|.
2011-09-10 14:54:07 -04:00
*'g:ctrlp_clear_cache_on_exit'*
Set this to 0 to enable cross-sessions caching: >
2011-09-10 14:54:07 -04:00
let g:ctrlp_clear_cache_on_exit = 1
<
2011-09-10 08:51:49 -04:00
2011-08-21 22:14:00 -04:00
*'g:ctrlp_cache_dir'*
Set the parent directory for the '.ctrlp_cache' directory: >
let g:ctrlp_cache_dir = $HOME
<
*'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 youve changed the values (inside []): >
let g:ctrlp_prompt_mappings = {
\ 'PrtBS()': ['<bs>'],
\ 'PrtDelete()': ['<del>'],
\ 'PrtDeleteWord()': ['<c-w>'],
\ 'PrtClear()': ['<c-u>'],
\ 'PrtSelectMove("j")': ['<c-j>', '<down>'],
\ 'PrtSelectMove("k")': ['<c-k>', '<up>'],
\ 'PrtHistory(-1)': ['<c-n>'],
\ 'PrtHistory(1)': ['<c-p>'],
\ 'AcceptSelection("e")': ['<cr>'],
\ 'AcceptSelection("h")': ['<c-x>', '<c-cr>', '<c-s>'],
\ 'AcceptSelection("t")': ['<c-t>'],
\ 'AcceptSelection("v")': ['<c-v>', '<c-q>'],
\ 'ToggleFocus()': ['<tab>'],
\ 'ToggleRegex()': ['<c-r>'],
\ 'ToggleByFname()': ['<c-d>'],
\ 'ToggleType(1)': ['<c-f>', '<c-up'],
\ 'ToggleType(-1)': ['<c-b>', '<c-down>'],
\ 'PrtCurStart()': ['<c-a>'],
\ 'PrtCurEnd()': ['<c-e>'],
\ 'PrtCurLeft()': ['<c-h>', '<left>'],
\ 'PrtCurRight()': ['<c-l>', '<right>'],
\ 'PrtClearCache()': ['<F5>'],
\ 'CreateNewFile()': ['<c-y>'],
\ 'MarkToOpen()': ['<c-z>'],
\ 'OpenMulti()': ['<c-o>'],
\ 'PrtExit()': ['<esc>', '<c-c>', '<c-g>'],
2011-08-21 22:14:00 -04:00
\ }
<
*'g:ctrlp_mru_files'*
Set this to 0 to completely disable the Most Recently Used files feature: >
let g:ctrlp_mru_files = 1
<
*'g:ctrlp_mruf_max'*
Specify the number of recently opened files you want |CtrlP| to remember: >
let g:ctrlp_mruf_max = 150
<
*'g:ctrlp_mruf_exclude'*
Files you dont want |CtrlP| to remember; use |regexp| to specify the patterns:
>
let g:ctrlp_mruf_exclude = ''
<
Examples: >
let g:ctrlp_mruf_exclude = '/tmp/.*\|/temp/.*' " MacOSX/Linux
let g:ctrlp_mruf_exclude = '^C:\\dev\\tmp\\.*' " Windows
<
*'g:ctrlp_mruf_include'*
And if you want |CtrlP| to only remember some files, specify them here: >
let g:ctrlp_mruf_include = ''
<
Example: >
2011-09-07 17:01:08 -04:00
let g:ctrlp_mruf_include = '\.py$\|\.rb$'
<
2011-09-09 20:32:08 -04:00
*'g:ctrlp_dotfiles'*
2011-09-11 12:53:32 -04:00
Set this to 0 if you dont want |CtrlP| to search for dotfiles and dotdirs: >
2011-09-09 20:32:08 -04:00
let g:ctrlp_dotfiles = 1
<
2011-09-11 18:49:42 -04:00
You can also use |'wildignore'| to exclude anything from the search.
e.g. exclude version control directories from the results: >
2011-09-13 13:17:20 -04:00
set wildignore+=*/.git/*,*/.hg/*,*/.svn/* " Linux/MacOSX
set wildignore+=.git\*,.hg\*,.svn\* " Windows
2011-09-11 18:49:42 -04:00
<
2011-09-14 17:57:51 -04:00
Note: the `*/` in front of each dotfile glob is required for the dotfiles
search feature to work correctly along side with |wildignore|. If youve
disabled dotfiles search (set |g:ctrlp_dotfiles| to 0), then you can ignore
this.
2011-09-09 20:32:08 -04:00
2011-10-19 16:58:28 -04:00
Other note: |wildignore| influences the result of |expand()|, |globpath()| and
2011-10-19 17:09:44 -04:00
|glob()| which many plugins use to find stuff on the system (e.g. fugitive.vim
looks for .git/, some other plugins look for external .exe tools on Windows).
So be a little mindful of what you put in your |wildignore|.
2011-10-19 16:58:28 -04:00
2011-09-11 12:53:32 -04:00
*'g:ctrlp_highlight_match'*
Use this to enable/disable highlighting of the matched patterns and to specify
the highlight group thatll be used: >
let g:ctrlp_highlight_match = [1, 'Identifier']
2011-09-11 12:53:32 -04:00
<
*'g:ctrlp_max_files'*
The maximum number of files to scan, set to 0 for no limit: >
let g:ctrlp_max_files = 20000
<
*'g:ctrlp_max_depth'*
The maximum depth of a directory tree to recurse into: >
let g:ctrlp_max_depth = 40
<
2011-11-02 19:09:12 -04:00
Note: the larger these values, the more memory Vim uses.
2011-09-11 12:53:32 -04:00
*'g:ctrlp_user_command'*
2011-11-02 19:09:12 -04:00
Specify an external tool to use for listing files instead of using Vims
globpath(). Use %s in place of the target directory: >
2011-09-11 12:53:32 -04:00
let g:ctrlp_user_command = ''
<
Examples: >
2011-09-11 17:26:18 -04:00
let g:ctrlp_user_command = 'find %s -type f' " MacOSX/Linux
let g:ctrlp_user_command = 'dir %s /-n /b /s /a-d' " Windows
<
You can also use 'grep', 'findstr' or something else to filter the results.
Examples: >
let g:ctrlp_user_command = 'find %s -type f | grep (?!tmp/.*)'
let g:ctrlp_user_command = 'dir %s /-n /b /s /a-d | findstr .*\.py$'
2011-09-11 12:53:32 -04:00
<
2011-11-02 19:09:12 -04:00
Use a version control listing command when inside a repository: >
let g:ctrlp_user_command = [marker, command, secondary_command]
<
2011-11-02 19:09:12 -04:00
If the secondary_command is empty or not defined, globpath() will be used when
outside a repo. Examples: >
let g:ctrlp_user_command = ['.git/', 'cd %s && git ls-files']
let g:ctrlp_user_command = ['.hg/', 'hg --cwd %s locate --fullpath -I .']
<
2011-09-11 12:53:32 -04:00
*'g:ctrlp_open_new_file'*
Use this option to specify how the newly created file is to be opened when
pressing <c-y>:
1 - in a new tab
2 - in a new horizontal split
3 - in a new vertical split
0 - in the current window
>
let g:ctrlp_open_new_file = 3
<
*'g:ctrlp_max_history'*
The maximum number of input strings you want |CtrlP| to remember. The default
value mirrors Vims global |'history'| option. E.g. `set history=50`: >
let g:ctrlp_max_history = &history
<
Set to 0 to disable prompts history.
*'g:ctrlp_open_multi'*
If non-zero this will enable opening multiple files with <c-z> and <c-o>: >
let g:ctrlp_open_multi = 1
<
If bigger than 1, itll be used as the maximum number of windows to create when
opening the files (the rest will be hidden buffers). If is 1, <c-o> will open
all files, each in a vertical split.
2011-08-21 22:14:00 -04:00
===============================================================================
3. Commands *ctrlp-commands*
*:CtrlP*
2011-09-11 17:26:18 -04:00
:CtrlP [starting-directory]
2011-11-02 19:09:12 -04:00
Open the |CtrlP| prompt in find file mode.
2011-09-11 12:53:32 -04:00
If no argument is given, the value of |g:ctrlp_working_path_mode| will be
2011-09-12 21:27:27 -04:00
used to determine the starting directory.
2011-11-02 19:09:12 -04:00
You can use <tab> to auto-complete the [starting-directory] when typing it.
2011-09-05 07:05:04 -04:00
*:CtrlPBuffer*
:CtrlPBuffer
2011-11-02 19:09:12 -04:00
Open the |CtrlP| prompt in find buffer mode.
*:CtrlPMRUFiles*
:CtrlPMRUFiles
2011-11-02 19:09:12 -04:00
Open the |CtrlP| prompt in find Most-Recently-Used file mode.
2011-08-21 22:14:00 -04:00
*:ClearCtrlPCache*
:ClearCtrlPCache
2011-11-02 19:09:12 -04:00
Flush the cache for the current working directory. Same as pressing <F5>
inside |CtrlP|.
2011-08-21 22:14:00 -04:00
*:ClearAllCtrlPCaches*
:ClearAllCtrlPCaches
2011-09-14 17:57:51 -04:00
Delete all the cache files saved in |ctrlp_cache_dir|.
2011-08-21 22:14:00 -04:00
*:ResetCtrlP*
:ResetCtrlP
Reset all options, take in new values of the option variables (section 2).
2011-09-11 12:53:32 -04:00
The following commands ignore the value of |g:ctrlp_working_path_mode|:
2011-09-08 14:25:01 -04:00
*:CtrlPCurWD*
:CtrlPCurWD
This acts like |:CtrlP| with |path_mode| = 0
Find files in the |current-directory|.
2011-09-08 14:25:01 -04:00
*:CtrlPCurFile*
:CtrlPCurFile
This acts like |:CtrlP| with |path_mode| = 1
Find files in the same directory as the active buffer, regardless of what
the |current-directory| is.
2011-09-08 14:16:12 -04:00
*:CtrlPRoot*
:CtrlPRoot
This acts like |:CtrlP| with |path_mode| = 2
Find files in the projects root directory.
Check |working_path_mode| to see how |CtrlP| finds a root.
2011-09-08 14:16:12 -04:00
2011-08-21 22:14:00 -04:00
===============================================================================
4. Mappings *ctrlp-mappings*
*'ctrlp-<c-p>'*
<c-p>
Default |Normal| mode mapping to open the |CtrlP| prompt.
Once inside the prompt:
<c-r> *'ctrlp-fullregexp'*
2011-09-12 21:27:27 -04:00
Toggle between the string mode (section 5.a & b) and full |regexp| mode.
2011-08-21 22:14:00 -04:00
(note: in full |regexp| mode, the prompts base is 'r>>' instead of '>>>')
2011-09-11 12:53:32 -04:00
See also |input-formats| and |g:ctrlp_regexp_search|.
2011-08-21 22:14:00 -04:00
<c-d>
2011-09-05 10:59:18 -04:00
Toggle between full path search and filename only search.
(note: in filename mode, the prompts base is '>d>' instead of '>>>')
2011-08-21 22:14:00 -04:00
<c-f>, 'forward'
<c-up>
Scroll to the 'next' search type in the sequence. Currently file, buffer
and most recently used file (MRU) are available.
<c-b>, 'backward'
<c-down>
Scroll to the 'previous' search type in the sequence.
2011-09-05 07:05:04 -04:00
2011-09-05 10:59:18 -04:00
<tab>
Toggle the focus between the match window and the prompt.
2011-08-21 22:14:00 -04:00
<c-j>,
<down>
Move selection down
<c-k>,
<up>
Move selection up
<c-a>
Move the cursor to the 'start' of the prompt
<c-e>
Move the cursor to the 'end' of the prompt
<c-h>,
<left>
Move the cursor one character to the 'left'
<c-l>,
<right>
Move the cursor one character to the 'right'
<c-w>
2011-09-11 12:53:32 -04:00
Delete a preceding inner word
2011-08-21 22:14:00 -04:00
<c-u>
Clear the input field
<cr>
Open selected file with the method specified with |g:ctrlp_split_window|
<c-t>
Open selected file in a new 'tab'
<c-v>
Open selected file in a 'vertical' split
<c-cr>,
2011-09-28 09:42:52 -04:00
<c-s>,
<c-x>
2011-08-21 22:14:00 -04:00
Open selected file in a 'horizontal' split
<c-y>
Create a new file and its parent directories.
<c-n>
'Next' string in the prompts history
<c-p>
'Previous' string in the prompts history
<c-z>
Mark/unmark a file to be opened with <c-o>.
<c-o>
Open files marked by <c-z>.
2011-09-08 11:50:57 -04:00
<F5>
2011-09-10 14:54:07 -04:00
Refresh the match window and purge the cache for the current directory.
2011-11-02 19:09:12 -04:00
Or remove deleted files from MRU list.
2011-09-08 11:50:57 -04:00
2011-08-21 22:14:00 -04:00
<esc>,
<c-c>,
<c-g>
2011-11-02 19:09:12 -04:00
Exit |CtrlP|. <c-c> can also be used to stop the file scan.
2011-08-21 22:14:00 -04:00
Chose your own mappings with |g:ctrlp_prompt_mappings|.
When inside the match window (press <tab> to switch):
2011-09-11 12:53:32 -04:00
a-z
0-9
~^-=;`',.+!@#$%&_(){}[]
2011-09-14 18:16:15 -04:00
Cycle through the lines with the first letter (of paths or filenames) that
matches that key.
2011-09-11 12:53:32 -04:00
2011-08-21 22:14:00 -04:00
===============================================================================
5. Input Formats *ctrlp-input-formats*
*ctrlp-prompt-input-formats*
Formats for inputting in the prompt:
2011-11-02 19:09:12 -04:00
a) Simple string.
e.g. 'abc' is understood internally as 'a[^a]\{-}b[^b]\{-}c'
2011-08-21 22:14:00 -04:00
2011-09-12 21:27:27 -04:00
b) Vim |regexp|. If the input string contains '*' or '|', itll be treated as
a Vims |regexp| |pattern| without any modification.
2011-08-21 22:14:00 -04:00
e.g. 'abc\d*efg' will be read as 'abc\d*efg'.
See also |ctrlp-fullregexp| (key map) and |g:ctrlp_regexp_search| (option).
2011-08-21 22:14:00 -04:00
c) End the string with a colon ':' followed by a Vim command to execute that
command after opening the file. If you need to use ':' in the command,
escape it with a backslash: '\:'.
2011-09-05 10:59:18 -04:00
e.g. 'abc:45' will open the selected file and jump to line 45.
'abc:/my\:function' will open the selected file and jump to the first
instance of 'my:function'.
'abc:+setf\ myfiletype|50' will open the selected file and set its
filetype to 'myfiletype' then jump to line 50.
2011-11-02 19:09:12 -04:00
See also Vims |++opt| and |+cmd|.
2011-09-05 10:59:18 -04:00
d) Type exactly two dots (..) at the start of the line and press enter to go
backward in the directory tree by 1 level. If the parent directory is
large, this might be slow.
e) Type the name of a non-existent file and press <c-y> to create it.
e.g. 'parentdir/file.txt' will create a directory named 'parentdir' as well
as 'file.txt'. Use '\' in place of '/' on Windows (if |'ssl'| is not set).
2011-10-08 10:42:18 -04:00
f) Submit ? to open this help file.
2011-08-21 22:14:00 -04:00
===============================================================================
EXTENDING *ctrlp-extending*
Extending |CtrlP| is made to be incredibly simple. Just create a .vim file
following a short guidelines, place the file in the right spot and add a line
to your .vimrc.
To see how it all works, get the sample.vim from the 'extensions' branch on the
git repository (https://github.com/kien/ctrlp.vim/tree/extensions), and place
it (along with the parent directories) somewhere in your runtimepath. Then put
this into your .vimrc: >
let g:ctrlp_extensions = ['sample']
<
A 4th search type will show up the next time you open |CtrlP|.
For more details, check out the comments inside sample.vim.
===============================================================================
CREDITS *ctrlp-credits*
2011-08-21 22:14:00 -04:00
2011-11-02 19:09:12 -04:00
Developed by Kien Nguyen (github.com/kien), primarily based on the Command-T
and the LustyExplorer plugins. No code was taken from these plugins, but I did
clone the majority of their (awesome) interfaces and the way they work.
2011-08-21 22:14:00 -04:00
The was originally written as a module for a would-be larger plugin called
AutoDoc.vim which Ive stopped developing because of lost of interest. I really
liked the way Command-T and LustyExplorer deal with users input, so I wrote a
pure Vimscript version of their prompt window, intended to use it for the
aforementioned plugin.
2011-08-21 22:14:00 -04:00
Homepage: http://kien.github.com/ctrlp.vim
2011-09-05 07:21:42 -04:00
Git repository: https://github.com/kien/ctrlp.vim
Mercurial repository: https://bitbucket.org/kien/ctrlp.vim
2011-08-21 22:14:00 -04:00
===============================================================================
THANKS *ctrlp-thanks*
Thanks to everyone that has submitted ideas, bug reports, helped debugging or
2011-11-02 19:09:12 -04:00
came up with solutions on gibhub, bitbucket, and through email.
===============================================================================
CHANGELOG *ctrlp-changelog*
2011-11-02 19:09:12 -04:00
Before 2011/10/30
2011-11-02 19:09:12 -04:00
+ New feature: Support for custom extensions.
<F5> now removes non-existent files from MRU list.
+ New option: |g:ctrlp_jump_to_buffer|
2011-10-19 08:00:08 -04:00
Before 2011/10/12
+ New features: Open multiple files.
Pass Vims ++opt and +cmd to the opening file (section 5.c)
Auto-complete each dir for |:CtrlP| [starting-directory]
+ New mappings: <c-z> mark/unmark a file to be opened with <c-o>.
<c-o> open all marked files.
+ New option: |g:ctrlp_open_multi|
+ Remove |g:ctrlp_persistent_input|, |g:ctrlp_live_update| and <c-^>.
Before 2011/09/29
+ New mappings: <c-n>, <c-p> next/prev string in the input history.
<c-y> create a new file and its parent dirs.
+ New options: |g:ctrlp_open_new_file|,
|g:ctrlp_max_history|
2011-09-28 09:42:52 -04:00
+ Added a new open-in-horizontal-split mapping: <c-x>
Before 2011/09/19
+ New command: |ResetCtrlP|
+ New options: |g:ctrlp_max_files|,
|g:ctrlp_max_depth|,
|g:ctrlp_live_update|
+ New mapping: <c-^>
2011-09-12 21:27:27 -04:00
Before 2011/09/12
2011-09-11 12:53:32 -04:00
+ Ability to cycle through matched lines in the match window.
2011-09-10 06:07:48 -04:00
+ Extended the behavior of |g:ctrlp_persistent_input|
2011-09-11 17:26:18 -04:00
+ Extended the behavior of |:CtrlP|
+ New options: |g:ctrlp_dotfiles|,
|g:ctrlp_clear_cache_on_exit|,
|g:ctrlp_highlight_match|,
|g:ctrlp_user_command|
+ New input format: '..' (section 5.d)
2011-09-08 11:50:57 -04:00
+ New mapping: <F5>.
+ New commands: |:CtrlPCurWD|,
|:CtrlPCurFile|,
|:CtrlPRoot|
2011-09-08 11:50:57 -04:00
+ New feature: Search in most recently used (MRU) files
+ New mapping: <c-b>.
+ Extended the behavior of <c-f>.
+ New options: |g:ctrlp_mru_files|,
|g:ctrlp_mruf_max|,
|g:ctrlp_mruf_exclude|,
|g:ctrlp_mruf_include|
+ New command: |:CtrlPMRUFiles|
First public release: 2011/09/06
2011-08-21 22:14:00 -04:00
===============================================================================
2011-09-28 09:42:52 -04:00
vim:et:ts=2:sw=2:sts=2