ctrlp.vim/doc/ctrlp.txt

428 lines
16 KiB
Plaintext
Raw Normal View History

2011-09-07 11:10:52 -04:00
*ctrlp.txt* Full path fuzzy file, buffer and MRU file finder for Vim.
2011-08-21 22:14:00 -04:00
*CtrlP* *ControlP* *'ctrlp'* *'ctrl-p'*
===============================================================================
# #
# :::::::: ::::::::::: ::::::::: ::: ::::::::: #
# :+: :+: :+: :+: :+: :+: :+: :+: #
# +:+ +:+ +:+ +:+ +:+ +:+ +:+ #
# +#+ +#+ +#++:++#: +#+ +#++:++#+ #
# +#+ +#+ +#+ +#+ +#+ +#+ #
# #+# #+# #+# #+# #+# #+# #+# #
# ######## ### ### ### ########## ### #
# #
===============================================================================
CONTENTS *ctrlp-contents*
1.Intro...................................|ctrlp-intro|
2.Options.................................|ctrlp-options|
3.Commands................................|ctrlp-commands|
4.Mappings................................|ctrlp-mappings|
5.Input Formats...........................|ctrlp-input-formats|
6.Credits.................................|ctrlp-credits|
===============================================================================
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, and more.
2011-08-21 22:14:00 -04:00
See also |ctrlp-input-formats| and |ctrlp-fullregexp|.
===============================================================================
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'*
Set this to 1 to set full |regexp| search as the default mode: >
let g:ctrlp_regexp_search = 0
<
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
<
2011-09-07 17:01:08 -04:00
*'g:ctrlp_persistent_input'*
2011-09-10 06:07:48 -04:00
Remember the last input string. Set this to 2 to also remember the last
position of the selection in the match window and 0 to completely disable this
feature: >
2011-09-07 17:01:08 -04:00
let g:ctrlp_persistent_input = 1
2011-08-21 22:14:00 -04:00
<
*'g:ctrlp_split_window'*
Use this option to specify how the file is to be opened when pressing <cr>:
1 - in a new tab
2 - in a new horizontal split
3 - in a new vertical split
0 - in the current window/split
>
let g:ctrlp_split_window = 0
<
*'g:ctrlp_ignore_space'*
2011-09-12 21:27:27 -04:00
Set this to 1 to ignore whitespaces in filenames and directory names: >
let g:ctrlp_ignore_space = 0
2011-08-21 22:14:00 -04:00
<
*'g:ctrlp_working_path_mode'*
*SetWorkingPath()*
When starting up the prompt, automatically set the working directory (i.e. the
|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 = 1
<
You can use this functionality outside of |CtrlP| by adding the following line
to your |.vimrc|; the parameter is the same (1, 2 and 0): >
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
2011-09-06 09:19:49 -04:00
addition to the default ones: >
2011-09-06 09:03:31 -04:00
let g:ctrlp_root_markers = ['']
<
2011-08-21 22:14:00 -04:00
*'g:ctrlp_max_height'*
Set the maximum height of the match window: >
let g:ctrlp_max_height = 10
<
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
<
2011-09-10 14:54:07 -04:00
Note: you can quickly purge the cache by pressing <F5>.
*'g:ctrlp_clear_cache_on_exit'*
2011-09-11 12:53:32 -04:00
Set this to 0 to enable cross-sessions caching by not deleting the caches upon
2011-09-10 14:54:07 -04:00
exit: >
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-n>', '<c-j>', '<down>'],
\ 'PrtSelectMove("k")': ['<c-p>', '<c-k>', '<up>'],
\ 'AcceptSelection("e")': ['<cr>'],
\ 'AcceptSelection("h")': ['<c-cr>', '<c-s>'],
\ 'AcceptSelection("t")': ['<c-t>'],
\ 'AcceptSelection("v")': ['<c-v>'],
\ 'ToggleFocus()': ['<tab>'],
\ 'ToggleRegex()': ['<c-r>'],
\ 'ToggleByFname()': ['<c-d>'],
\ 'ToggleType(1)': ['<c-f>', '<c-up'],
\ 'ToggleType(-1)': ['<c-b>', '<c-down>'],
2011-08-21 22:14:00 -04:00
\ 'PrtCurStart()': ['<c-a>'],
\ 'PrtCurEnd()': ['<c-e>'],
\ 'PrtCurLeft()': ['<c-h>', '<left>'],
\ 'PrtCurRight()': ['<c-l>', '<right>'],
2011-09-08 11:50:57 -04:00
\ 'PrtClearCache()': ['<F5>'],
2011-08-21 22:14:00 -04:00
\ 'BufOpen("ControlP", "del")': ['<esc>', '<c-c>', '<c-g>'],
\ }
<
*'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 = 50
<
*'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: >
set wildignore+=.git/*,.hg/*,.svn/* " Linux/MacOSX
set wildignore+=.git\*,.hg\*,.svn\* " Windows
<
2011-09-09 20:32:08 -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, 'Function']
<
*'g:ctrlp_user_command'*
Specify an external tool to use for indexing files instead of Vims globpath().
Use %s in place of the target directory: >
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
<
2011-09-11 12:53:32 -04:00
2011-09-11 17:26:18 -04:00
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-08-21 22:14:00 -04:00
===============================================================================
3. Commands *ctrlp-commands*
*:CtrlP*
2011-09-11 17:26:18 -04:00
:CtrlP [starting-directory]
Open the |CtrlP| prompt in find files 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-09-05 07:05:04 -04:00
*:CtrlPBuffer*
:CtrlPBuffer
Open the |CtrlP| prompt in find buffers mode.
*:CtrlPMRUFiles*
:CtrlPMRUFiles
Open the |CtrlP| prompt in find Most-Recently-Used files mode.
2011-08-21 22:14:00 -04:00
*:ClearCtrlPCache*
:ClearCtrlPCache
Flush the cache for the current working directory.
*:ClearAllCtrlPCaches*
:ClearAllCtrlPCaches
Delete all the saved cache files in |ctrlp_cache_dir|.
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
2011-09-11 12:53:32 -04:00
Find files in the |current-directory|.
2011-09-08 14:25:01 -04:00
*:CtrlPCurFile*
:CtrlPCurFile
2011-09-11 12:53:32 -04:00
Find files in the same directory as the current file, regardless of what the
|current-directory| is.
2011-09-08 14:16:12 -04:00
*:CtrlPRoot*
:CtrlPRoot
2011-09-08 17:39:59 -04:00
Same as |:CtrlPCurFile| but start from the projects root.
2011-09-11 12:53:32 -04:00
Check |g:ctrlp_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>
Toggle between searching files and searching buffers. Or switch to the
'next' search type in the sequence; currently files, buffers and most
recently used files (MRU Files) are available.
<c-b>, 'backward'
<c-down>
Toggle between searching files and searching buffers. Or switch 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-n>,
<c-j>,
<down>
Move selection down
<c-p>,
<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>,
<c-s>
Open selected file in a 'horizontal' split
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-09-08 11:50:57 -04:00
2011-08-21 22:14:00 -04:00
<esc>,
<c-c>,
<c-g>
Exit |CtrlP|
Chose your own mappings with |g:ctrlp_prompt_mappings|.
2011-09-11 12:53:32 -04:00
When inside the match window (press <tab> to switch to):
a-z
0-9
~^-=;`',.+!@#$%&_(){}[]
Cycle through the lines with the first letter (paths or filenames) that
match that character.
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-09-08 14:16:12 -04:00
a) Simple string. e.g. 'abc' is understood internally as 'a.\{-}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'.
2011-09-11 12:53:32 -04:00
See also |ctrlp-fullregexp| and |g:ctrlp_regexp_search|.
2011-08-21 22:14:00 -04:00
2011-09-05 10:59:18 -04:00
c) Strings end with a colon ':' followed by an arbitrary number will be read
as a line number to jump to after opening the file.
e.g. 'abc:45' will open the selected file and jump to line 45.
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.
2011-08-21 22:14:00 -04:00
===============================================================================
6. Credits *ctrlp-credits*
Developed by Kien Nguyen (github.com/kien), 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.
This 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
2011-09-05 19:30:54 -04:00
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
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
===============================================================================
CHANGELOG
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|
2011-09-10 14:54:07 -04:00
+ New option: |g:ctrlp_dotfiles|,
2011-09-11 12:53:32 -04:00
|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
2011-09-07 11:10:52 -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|
2011-09-12 21:27:27 -04:00
The updates are shown in reverse chronological order, from newest (top) to
oldest (bottom).
2011-08-21 22:14:00 -04:00
===============================================================================
vim:nofen:et:ts=2:sw=2:sts=2