可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
I'm a long time Emacs user, but partially switched to MacVim 2 years ago, and have been using it for all my programming work (still using Emacs for other stuff). I decided to switch back to Emacs now, mainly because of the awesome evil-mode
. I'm quite happy, but I still haven't found something as good and simple as the Vim Command-T plugin.
The main problem with the Emacs alternatives is that they are either too complicated and or slow.
The closest thing to Command-T is helm
/helm-cmd-t
, but it doesn't quite work like it.
Let's say you have two paths:
app/controllers/admin/feedback_controller.rb
app/controllers/fee_controller.rb
In Vim's Command-T, you can write:
app/controllers/fe
And it will match both paths.
With helm-cmd-t
, if I write app/controllers/fee
, it will only match fee_controller
. If I want to match both, I have to use a regexp, as in app/controllers/.*
, which is not that bad, but requires more keystrokes.
Any suggestions appreciated!
回答1:
Any Emacs package that uses ido can do this, provided that ido-flex-match
is non-nil. Helm-cmd-t deliberately doesn't support this kind of flexible matching.
You can get the behaviour you describe using find-file-in-repository with ido-flex-match
set to 't
.
回答2:
I've recently started using flx
with ido-mode
and projectile
it has exceptionally good, ranked fuzzy matching and has a very similar feel to CtrlP and CmdT for Vim.
It can be installed via MELPA.
M-x package-install
flx
For more info see the flx project.
Here's a screengrab to illustrate...
回答3:
Here it is, but required helm to be installed first: https://github.com/emacs-helm/helm-cmd-t
EDIT: See my Helm guide. Read why it is powerful. See helm
with projectile
in action in that section.
With fuzzy searcher like Ido + flx or the like in Vim, you have to type thing in order.
With Helm, you can perform out of order matching.I called it out of order because whether I enter "main.c x86" or "x86 main.c", I get the same set of results for the either query. But it also makes sense to call it multi-steps search. Without having to enter the search strings (called "patterns", which are actually regexp) in an orderly fashion, Helm gives me greater freedom: I can enter the thing I wanted first in my mind without having to remember its complex path; if there are many candidates from the target I wanted, I narrow it down further with more details (patterns).
The above example to illustrate the two cases from the advantage above:
- If my desire target is not unique, fine I can narrow further.
- If my desire target is unique, I can immediately get it.
As you can see, the Linux kernel source tree contains more than 40kfiles, and I narrowed it down to a few files immediately.
Visual Studio also implements this mechanism in their project search, but it's not generic as Helm. In Helm, you can reuse the same Helm interface for many other things; for example, see helm-semantic-or-imenu
. You have something like an outline tree, but you can interactively and incrementally narrow to the candidates you want with a few simple patterns.
Finally, fyi, flx
author - Le Wang - is using Helm.
回答4:
Did you try LustyExplorer? It's based on the Vim plugin with the same name.
Also, it looks like you are not using Command-T to the best of its capabilities: acfe
should be enough for it to match those two files. What you do is not particularly better than :e app/con*/**/fe<Tab>
.
回答5:
I've once run across gpicker which advertises speed as one of its advantages over Ido and other "native" elisp packages. Never got to try it out on real-world projects though, but it might work for you.
回答6:
Long story short - there's nothing quite like command-T for Emacs. Best options are gpicker or Peepcode's peepopen, but they are external applications, and I find them to be distracting after using command-T for so long. I'll stick to MacVim for now, only because of command-T, but might look into implementing something that behaves just like command-T as an exercise.
Thank you all for the answers and comments!
回答7:
Give textmate.el a try :)
https://github.com/defunkt/textmate.el
You'll just have to use "Command+T" instead of "Ctrl+P" :)
回答8:
https://github.com/bling/fzf.el
This is the best solution out there in my opinion. Here's why:
- Uses projectile to determine project root if you're in a project.
- Otherwise it very quickly indexes the file in the current directory.
- Fuzzy matching.
- Can be customized (top or bottom placement, number of records, etc.)