My project has these files:
$ find . -type f -and -name 'peop*'
./app/assets/stylesheets/admin/sections/people.css.sass
./app/controllers/admin/people_controller.rb
As I got tired of typing :e app/assets/stylesheets/admin/sections/people.css.sass
, I thought that ctrlp might be a good way to save some typing. However, I can't get it to match files in what I consider to be a sane way.
First, I use <C-p>
and type peop
, and that gives me these results ("first" match is at the bottom):
> 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_
These results are horrible. Neither files with peop
in them are there. Even when I expand it to 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_
It doesn't list either of them (!)
I went through :help ctrlp-options
, and found a single option that improves things somewhat:
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.
After setting this, I get the following results on 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_
Okay, so this is slightly better, I get at least one of the expected files at the first result, and the other one as the 9th. It still conciders hulptabellen-object-unit-soort.pdf
to be a better match than people.css.sass
though (!)
Typing people
finally gives me the 2 expected files as the first 2:
> app/controllers/admin/organisation_people_controller.rb
> app/assets/stylesheets/admin/sections/people.css.sass
> app/controllers/admin/people_controller.rb
>>> people_
How can I make this matching better? I don't mind "fuzzy matching", but it should not be so fuzzy it matches everything and everyone... In this case, I would expect typing <c-P>peop
to have app/assets/stylesheets/admin/sections/people.css.sass
as either the 1st or 2nd match.
'g:ctrlp_match_func
A good example of this in use is this plugin: vim.org/scripts/script.php?script_id=4884