我的项目有以下文件:
$ find . -type f -and -name 'peop*'
./app/assets/stylesheets/admin/sections/people.css.sass
./app/controllers/admin/people_controller.rb
当我厌倦了打字时:e app/assets/stylesheets/admin/sections/people.css.sass
,我认为ctrlp可能是保存某些打字的好方法。但是,我无法以一种我认为理智的方式来匹配文件。
首先,我使用<C-p>
和键入peop
,这给了我这些结果(“第一”匹配在底部):
> app/models/attribute_group.rb
> app/models/contract_template.rb
> app/policies/contract_policy.rb
> app/uploaders/photo_uploader.rb
> app/policies/invoice_policy.rb
> app/views/layouts/pdf.pdf.haml
> app/uploaders/logo_uploader.rb
> app/models/property_object.rb
> app/policies/person_policy.rb
> app/policies/photo_policy.rb
>>> peop_
这些结果是可怕的。peop
它们中都没有文件。即使我将其扩展为people
:
> app/policies/contract_template_policy.rb
> app/models/concerns/exportable.rb
> app/models/contract_template.rb
> app/uploaders/photo_uploader.rb
> app/uploaders/logo_uploader.rb
> app/views/admin/people/_show.html.haml
> app/views/admin/people/_form.html.haml
> app/views/admin/people/show.html.haml
> app/views/admin/people/edit.html.haml
> app/views/admin/people/new.html.haml
>>> people_
它没有列出任何一个(!)
我经历了:help ctrlp-options
,发现了一个可以使事情有所改善的选项:
Set this to 1 to set searching by filename (as opposed to full path) as the
default:
let g:ctrlp_by_filename = 0
Can be toggled on/off by pressing <c-d> inside the prompt.
设置好之后,我得到以下结果peop
:
> app/controllers/admin/organisation_people_controller.rb
> app/assets/stylesheets/admin/sections/people.css.sass
> doc/formulieren/opdrachtverlening-woningbeheer.pdf
> doc/formulieren/hulptabellen-object-unit-soort.pdf
> doc/formulieren/brandpreventievoorjongeren.pdf
> app/policies/organisation_person_policy.rb
> doc/prototype-admin/prototype/inspectiemodule_apparaten.html
> app/policies/property_object_policy.rb
> app/policies/person_policy.rb
> app/controllers/admin/people_controller.rb
>d> peop_
好的,这样稍微好一点,我在第一个结果中至少得到了一个预期的文件,而在第9个结果中得到了另一个。它仍然认为hulptabellen-object-unit-soort.pdf
比以前更好people.css.sass
(!)
打字people
终于给了我2个预期的文件,作为第一个2:
> app/controllers/admin/organisation_people_controller.rb
> app/assets/stylesheets/admin/sections/people.css.sass
> app/controllers/admin/people_controller.rb
>>> people_
如何使这种匹配更好?我不介意“模糊匹配”,但它不应该是这样的模糊它匹配的一切,每个人都......在这种情况下,我希望打字<c-P>peop
有app/assets/stylesheets/admin/sections/people.css.sass
作为无论是第一或第二的比赛。
'g:ctrlp_match_func
该插件下的文档中。使用此插件的一个很好的例子是此插件:vim.org/scripts/script.php?script_id=4884