DEV Community

Cover image for 5 Minutes Vim: CtrlP considered harmful

5 Minutes Vim: CtrlP considered harmful

Jaime González García on January 01, 2020

This article was originally posted in barbarianmeetscoding.com. 😊 In this 5 minutes of Vim goodness we'll break the shackles of convention and bec...
Collapse
 
zkochan profile image
Zoltan Kochan • Edited

Clickbait title😃 I thought it will be about why using fzf is a bad idea.

For me, <leader>+s is not necessarily a lot easier than ctrl+p. IMHO, <leader>+ would be nicer.

I frequently use <leader>+n, which for me focuses the file in nerdtree. I usually work in a monorepo with many small packages and from there I can find the necessary file easily. That's faster than searching the file by name.

Collapse
 
vintharas profile image
Jaime González García

hahaha I meant it in the literal sense but I understand what you mean. :D

Using fzf or something like it is a GREEEAT idea. I think that jumping from not having it to using it dwarves in comparison to which mapping to use to trigger the find file behavior. But I have had problems with my wrists and I find like less I stress them the better.

Awesome! I have the same mapping for exactly the same thing hehe. But I don't rely on it so much. Only if I'm in an unknown codebase. In that case is a great way to explore around.

Thank you for your comment! :D

Collapse
 
kevinkoltz profile image
Kevin Koltz • Edited

I found it really useful to map escape to CtrlPBuffer in normal mode which makes it quick to jump back recent files or to the last used file with esc then enter. Then map leader space (or space space) to CtrlP for all files which is used less.

Collapse
 
vintharas profile image
Jaime González García

Uuu that sounds interesting. Is ESC on your Capslock position?

I might steal something of that :D

Collapse
 
kevinkoltz profile image
Kevin Koltz

Yeah, mapping caps lock to escape works really well until you go to use someone else's computer ;).

Collapse
 
ghost profile image
Ghost

I like to keep a lot of files open in my i3 with 3 screens, I'm primitive like that, that's why I love (n)vim and my lightweight XFCE4-terminal :)

By the way, when you have 20+ terminals open, xfce4-terminal eats less RAM than Qterminal and even st!

Collapse
 
vlasales profile image
Vlastimil Pospichal • Edited

I use <space> for switch into insert mode. A comma is much better as the <leader>.

Collapse
 
vintharas profile image
Jaime González García

Cool! Hadn't thought of that :D Sounds like a very pleasant way to go into insert mode.

I don't know about the comma though, I find it hard to reach.

Thanks for your comment! :)

Collapse
 
vlasales profile image
Vlastimil Pospichal

I always write a space after the comma. If a comma is followed by another key, it is a command in insert mode.

Collapse
 
eligoh profile image
Elijah Goh • Edited

I've dropped Ctrl+P altogether and just used this command. Just type and press tab.

:e **/*
Enter fullscreen mode Exit fullscreen mode

Skimmed off some boot time.

Collapse
 
philt profile image
Phil Thompson

Could you expand on this (haha!)? This is not fuzzy find. If you start typing again omnifunc will disappear. It also takes several seconds to populate. If you work on any decent size project this option does not scale as far as I can tell.

Collapse
 
eligoh profile image
Elijah Goh

It depends on what you're searching for. For files I'm unsure of, I'll press tab and let fuzzy finder do the work.

// Not very sure of file name but knowing the extension
:e **/MyUnsureFi*.vue

// Knowing which directory
:e app/controllers/**/my_controll
Enter fullscreen mode Exit fullscreen mode

If you scope down the directory, search will be faster. No plugins required. Asterisk only when necessary, scope down when you know the directory. Fast enough for me at least.

Collapse
 
wrldwzrd89 profile image
Eric Ahnell

I never would have thought to make sure the commands you define don't slow down touch typing, but you're right - this saves small bits of time that add up.