TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Sublime Text Ctrl+P Like Fuzzy Matching In Few Lines of Python

69 点作者 cplat将近 12 年前

9 条评论

crucialfelix将近 12 年前
It was actually me that suggested to the TextMate guy to do the fuzzy lookup in this way: matching significant characters in side the search term.<p>AFAIK Sublime, Ctrl-P and friends all followed and improved from TextMate&#x27;s version.<p>It was originally a feature in LaunchBar which was on NextStep and was ported to OS X [1] QuickSilver and Spotlight were also influenced by LaunchBar.<p>[1] <a href="http:&#x2F;&#x2F;www.obdev.at&#x2F;products&#x2F;launchbar&#x2F;legacy.html" rel="nofollow">http:&#x2F;&#x2F;www.obdev.at&#x2F;products&#x2F;launchbar&#x2F;legacy.html</a>
评论 #5888321 未加载
评论 #5892031 未加载
sorbits将近 12 年前
Source for TextMate’s ranker can be found here (GPLv3): <a href="https:&#x2F;&#x2F;github.com&#x2F;textmate&#x2F;textmate&#x2F;blob&#x2F;master&#x2F;Frameworks&#x2F;text&#x2F;src&#x2F;ranker.cc#L46-L192" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;textmate&#x2F;textmate&#x2F;blob&#x2F;master&#x2F;Frameworks&#x2F;...</a><p>And some tests here: <a href="https:&#x2F;&#x2F;github.com&#x2F;textmate&#x2F;textmate&#x2F;blob&#x2F;master&#x2F;Frameworks&#x2F;text&#x2F;tests&#x2F;t_ranker.cc" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;textmate&#x2F;textmate&#x2F;blob&#x2F;master&#x2F;Frameworks&#x2F;...</a>
pjscott将近 12 年前
If you want to give more weight to matches of consecutive characters, or do other fancy things, a sequence alignment algorithm could be useful:<p><a href="http:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Smith-Waterman_algorithm" rel="nofollow">http:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Smith-Waterman_algorithm</a>
评论 #5888260 未加载
评论 #5888181 未加载
spencera将近 12 年前
A slightly more sophisticated implementation: <a href="https:&#x2F;&#x2F;code.google.com&#x2F;p&#x2F;google-diff-match-patch&#x2F;" rel="nofollow">https:&#x2F;&#x2F;code.google.com&#x2F;p&#x2F;google-diff-match-patch&#x2F;</a>
cjh_将近 12 年前
I implemented something very similar in perl a few weeks back for my user interfaces project; I wrote a desktop search client that would take a query from the user and score results based on how many and how well it matches a series of different interpretations of the query (fuzzy was one of them).<p>I too am really amazed this isn&#x27;t more prevalent as it is so easy to do, after discovering the vim ctrl-p [1] plugin I rarely go a day without using it.<p>[1] <a href="https:&#x2F;&#x2F;github.com&#x2F;kien&#x2F;ctrlp.vim" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;kien&#x2F;ctrlp.vim</a>
dangoor将近 12 年前
For Brackets, I went with something that&#x27;s not a regex because I wanted certain parts of the string to be &quot;special&quot;:<p><a href="http:&#x2F;&#x2F;www.blueskyonmars.com&#x2F;2013&#x2F;03&#x2F;26&#x2F;brackets-quick-open-thats-no-regex&#x2F;" rel="nofollow">http:&#x2F;&#x2F;www.blueskyonmars.com&#x2F;2013&#x2F;03&#x2F;26&#x2F;brackets-quick-open-...</a><p>But, I&#x27;ll definitely look up a couple of the links that people have posted here about some other algorithms (Smith-Waterman, for example).
wting将近 12 年前
I had to do something similar for autojump (fuzzy matching search string vs directories list).<p>I started hand rolling my own based on Damerau-Levenshtein, but it turns that Python already has a similar implementation in the difflib:<p><a href="http:&#x2F;&#x2F;docs.python.org&#x2F;2&#x2F;library&#x2F;difflib.html#difflib.get_close_matches" rel="nofollow">http:&#x2F;&#x2F;docs.python.org&#x2F;2&#x2F;library&#x2F;difflib.html#difflib.get_cl...</a>
DrJosiah将近 12 年前
I added similar functionality to my editor about 5 years ago after seeing a coworker use Sublime Text. I&#x27;m amazed that all editors don&#x27;t have it already.
评论 #5888027 未加载
评论 #5888410 未加载
gondo将近 12 年前
call me old school, but Ctrl + P should do print
评论 #5888226 未加载
评论 #5888460 未加载
评论 #5888311 未加载