好开关!所以你发现了CtrlP。它内置了广泛的文档。:h ctrlp
用于查看解释各种选项的完整 vimdocs。它将解释工作目录的一些重要设置,这对于良好的使用体验非常重要。以我使用的一些设置为例:
" The one you really care about...
" Set root to CWD. Another good option is 'r' for VCS mode.
" You should start vim in the root of your project tree
let g:ctrlp_working_path_mode = 0
" You _can_ switch dirs
let g:ctrlp_extensions = ['dir']
" Avoid big/unimportant project areas
set wildignore+=*/node_modules/*,*/build/*,*/components/*,*/_public/*,*/tmp/*,*/vendor/*
" Cache -- get used to pressing F5 on tree changes/additions
let g:ctrlp_use_caching = 1
let g:ctrlp_clear_cache_on_exit = 0
" Somewhat self-explanatory
let g:ctrlp_show_hidden = 1
let g:ctrlp_switch_buffer = 2
let g:ctrlp_max_depth = 6
let g:ctrlp_max_height = 50
" Open *h*orizontally and *j*ump to first win.
let g:ctrlp_open_multiple_files = 'hj'
" Use <C-d> to toggle
"let g:ctrlp_by_filename = 1
要进一步控制在工作树之外查找文件的位置,请参阅g:ctrlp_user_command
. 有一个使用dir
. 您会使用它,但要使用所需的额外路径。
您可能还想添加NerdTree,这是对 CtrlP 的一个很好的补充。这让人想起ST的侧边栏。使用它?
来获得帮助。它有一个菜单,可让您快速添加文件和目录,可能就像您不想要“将文件夹添加到项目”一样。
对于搜索和替换,请查看ag.vim。我将它映射到<leader>g
(意思是“grep”)。
上面提到的是我最喜欢的一些,但你应该探索 Vim 插件的世界来决定哪些其他插件值得采用。我建议您在新手时一次尝试一个,而不是有时不透明的“分发”。使插件管理更容易的工具是Vundle / Pathogen(选择一个)。