Command-T for Emacs?

2019-03-28 06:20发布

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!

8条回答
太酷不给撩
2楼-- · 2019-03-28 06:39

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>.

查看更多
放荡不羁爱自由
3楼-- · 2019-03-28 06:47

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.

查看更多
一夜七次
4楼-- · 2019-03-28 06:48

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...

flx fuzzy matching

查看更多
家丑人穷心不美
5楼-- · 2019-03-28 06:53

Give textmate.el a try :) https://github.com/defunkt/textmate.el

You'll just have to use "Command+T" instead of "Ctrl+P" :)

查看更多
混吃等死
6楼-- · 2019-03-28 06:58

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楼-- · 2019-03-28 07:00

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.

查看更多
登录 后发表回答