TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Ctrl-P for Vim: Pure Vimscript Command-T

196 pointsby nwjsmithabout 13 years ago
I didn't write it but I thought HNers would be interested.<p>Send praise to https://github.com/kien!

33 comments

adamesqueabout 13 years ago
Ctrl-P does something that I wanted Command-T to do for a long, long time: if you invoke it and select a file that is already open in an existing window somewhere, rather than open a new window for that file, it will switch to the already-opened one.<p>You can change how this works, too: look up ctrlp_switch_buffer in the docs.
评论 #3913078 未加载
评论 #3910454 未加载
评论 #3910000 未加载
jpkabout 13 years ago
I use vim for coding just about every day, and as a rule, I try not to install plugins unless I <i>really</i> need/want it. Reason being is if, on occasion, I need to do a little editing inside an ec2 instance, or whatever, I don't want to type `vi` at the shell and get a different editor than the one I use every day. So I try to keep it as stock as possible, while allowing enough customization to be productive and comfortable.<p>Anyway, that said, Ctrl-P makes the cut. :)
评论 #3912027 未加载
评论 #3910786 未加载
评论 #3912695 未加载
评论 #3917717 未加载
aidosabout 13 years ago
Great plugin. I love that it tracks up to the nearest .git etc folder to decide where to search from. That's a killer feature.
edanmabout 13 years ago
I've used this plugin since I discovered it. It replaced fuzzy finder for me.<p>It is MUCH better.<p>My killer feature: it will automatically avoid opening files in <i>special</i> buffers. I.e. if you ru. It inside the NERDtree window, it won't load there but rather will load the file in the middle buffer.<p>Other than this it has loads of other things that make it much better.
nwjsmithabout 13 years ago
I didn't write it but I thought HNers would be interested.<p>Send praise to <a href="https://github.com/kien" rel="nofollow">https://github.com/kien</a>!
ghost91about 13 years ago
<a href="https://github.com/wincent/Command-T" rel="nofollow">https://github.com/wincent/Command-T</a><p>Is also quite good.<p>It would cool to have a performance comparison
评论 #3909980 未加载
评论 #3909826 未加载
评论 #3909803 未加载
评论 #3915669 未加载
评论 #3910466 未加载
评论 #3909829 未加载
padenotabout 13 years ago
It seems fast enough to use on mozilla-central (the Firefox repo), which is huge.<p>I can't find some files, though. If I type :<p>ctrp+p, mediaelement, it should find content/html/content/src/nsHTMLMediaElement.cpp, and it does not. I tried to set the maximum depth, but it didn't work. In fact, it does not match content/html/content files.<p>Another thing that I find annoying, is that when I remove multiple characters, it does its matching thing again, and because I type the backspace pretty fast, it kind of locks up for a second or so.<p>Anyway, other the couple quirks mentionned, excellent plugin, works out of the box.
评论 #3909957 未加载
评论 #3911070 未加载
joakinabout 13 years ago
Can somebody please point out the differences with a customized FuzzyFinder?<p>As I have it I get fuzzy completion from the root folder, opening splits with &#60;c-j&#62; and &#60;c-k&#62;, opening tabs with the file with &#60;c-l&#62;, deleting buffers from the list with &#60;c-]&#62;, and such.<p>Is there any difference or improvement one should try? Genuine question, I am really curious. It would be great to see a comparative between FuzzyFinder, Command-T and Ctrl-P...<p>ps: fuzz config is like this in vimrc:<p><pre><code> " Fuzzy Finder nnoremap &#60;leader&#62;fr :FufRenewCache&#60;CR&#62; nnoremap &#60;leader&#62;ff :FufFile **/&#60;CR&#62; nnoremap &#60;leader&#62;ff :FufFile **/&#60;CR&#62; nnoremap &#60;leader&#62;fg ye :FufFile **/&#60;C-r&#62;"&#60;CR&#62; vnoremap &#60;leader&#62;fg y :FufFile **/&#60;C-r&#62;"&#60;CR&#62; nnoremap &#60;leader&#62;fb :FufBuffer&#60;CR&#62; nnoremap &#60;leader&#62;fd :FufDirWithCurrentBufferDir&#60;CR&#62; nnoremap &#60;leader&#62;fl :FufLine&#60;CR&#62; </code></pre> (Ignore the maps, thats how I like it)<p>Edit: I would like to point out that I have skimmed several times through the docs of Fuzzy Finder and there are several options I dont even use/grasp, so more knowledge and tips on Fuzzy Finder would be appreciated also
评论 #3911463 未加载
评论 #3910586 未加载
base698about 13 years ago
After 2 weeks of using Sublime I just did this:<p>rm -rf /Applications/Sublime\ Text\ 2.app/<p>I will never neglect you again VIM. You've been so good to all of us.
jamesgeck0about 13 years ago
Hitting Ctrl-F or :ControlTFlush so I can open a file that Rails or Git or whatever added to the project directory is one of my biggest issues with Command-T. Sublime Text 2 gets it right, but it's Vim compatibility mode isn't quite there yet.<p>Will this automatically update its cache as new files are added?
评论 #3912944 未加载
cgagabout 13 years ago
I have this installed as it comes with Janus (<a href="https://github.com/carlhuda/janus" rel="nofollow">https://github.com/carlhuda/janus</a>), and it's excellent. I tried to get Command-T to work in the past and failed, but this works with no problems, and is incredibly useful.
owenjonesabout 13 years ago
Awesome to not have to compile this with (SYSTEM!) ruby.
jpkabout 13 years ago
Protip for python hackers: "set wildignore+=*.pyc" in your .vimrc so Ctrl-P won't pick up all the .pyc files. It's pretty annoying to get every file you search for 2x, and then get a bunch of binary junk if you pick the wrong one. :-P
mrinterwebabout 13 years ago
I regularly use Ctrl-P and Command-T regularly. Ctrl-P seems to work well for smaller projects. It is faster than Command-T, but it often fails to find files accurately on larger projects. It searches in hidden/ignored directories that Command-T automatically ignores. I like the fact that you don't have to have vim compiled with ruby support to use Ctrl-P which is great when working on remote machines. I feel like Ctrl-P is close to being a drop-in replacement for Command-T, but it is not quite there yet. When Ctrl-P's match results are the same as Command-T's, I'll stop using Command-T.
jh3about 13 years ago
If you're on Ubuntu and do not want to build vim with Ruby support, but still want to use Command-T for some reason, install vim-nox.<p>That being said, ctrlp is less of a headache since it's pure vimscript like the headline says.
评论 #3913486 未加载
hjklabout 13 years ago
Anybody have an opinion on ctrlp vs LustyExplorer? <a href="http://www.vim.org/scripts/script.php?script_id=1890" rel="nofollow">http://www.vim.org/scripts/script.php?script_id=1890</a>
评论 #3912018 未加载
wahnfriedenabout 13 years ago
How does this compare to FuzzyFinder? FuF has been far better than other options people espouse like Command-T but still has some warts of its own.
tommydabout 13 years ago
It was this feature which made me switch full-time to Sublime Text in the end - Command-T was just too slow in comparison so I decided the Vim emulation in Sublime was good enough for the commands I used, which are just the basics really - arguable how much of a speed difference it makes almost but it's too ingrained in muscle memory now! :wq
gregwebsabout 13 years ago
I love Ctrl-P! You can use Ctrl-B to search only open buffers.<p>Ctrl-P is the recommended find plugin from the janus vim distribution: <a href="https://github.com/carlhuda/janus" rel="nofollow">https://github.com/carlhuda/janus</a> I use most of the other plugins from there and will be trying out the others.
评论 #3912582 未加载
liamgriffithsabout 13 years ago
Love this plugin, makes vimming so much nicer and is my favorite file/buffer manager. I like you you can optionally keep the cache so when you reopen there isn't that delay for checking the directory tree too. let g:ctrlp_clear_cache_on_exit=0<p>Thanks to kien for making it!
DevMonkeyabout 13 years ago
Very Awesome! Commmand-T (vim plugin) has been an essental part of my workflow for years now. I can't live without it. The biggest thorn for setting up a new host is having to procure VIM with Ruby support. Thank you so much for doing this!
评论 #3910224 未加载
pp1616about 13 years ago
What's the easiest way to install this? I have pathogen if that makes any difference...
评论 #3910185 未加载
评论 #3910061 未加载
ianpurtonabout 13 years ago
It's truly a great tool. I installed it yesterday as an alternative to CTRL-T as I didn't want to install ruby system wide.<p>It will also allow you to quickly move between buffers with CTRL-P then CTRL-B to select buffers.
moeabout 13 years ago
Thanks for posting this!<p>I've been a longtime FuzzyFinder and Command-T user but both have pretty nasty warts. Crossing my fingers that this will finally be the one to do it right.
mcmireabout 13 years ago
&#62; Written in pure Vimscript<p>I'm so sorry :P<p>In all seriousness, this looks like a good contender to Command-T judging by a cursory glance through the README. I'll have to give it a shot.
评论 #3912725 未加载
alecbenzerabout 13 years ago
Is there a way to get it to open a file in a new tab instead of the current one? (instead of having to :tabnew and then invoking ctrlp)
评论 #3912980 未加载
ernestiparkabout 13 years ago
Is there a way to easily open a file into a split?
评论 #3910332 未加载
评论 #3910333 未加载
tmcwabout 13 years ago
I can attest this is awesome and works awesome.
shortlivedabout 13 years ago
Does anyone know how to change default search behavior from full-path to filename? I read the help but don't see the option...
评论 #3910169 未加载
astrecabout 13 years ago
I was using PeepOpen which is quite nice, but (of course) it doesn't work in the terminal. This looks quite spiffy.
timmorganabout 13 years ago
The readme says MacVim -- anyone know if this will work in GVim?
评论 #3910692 未加载
g3orgeabout 13 years ago
it takes a lot of time for the first launch to cache. Is this normal?
westcaveabout 13 years ago
Thank you, kien.