DEV Community

Discussion on: Supercharging Vim: Instant testing

Collapse
 
wulymammoth profile image
David • Edited

Heya Matt -- I'm just browsing Dev.to's #vim tag and came across your post. I recently discovered vim-test, too! It's been quite the improvement, but I didn't have a terrible flow before that I thought I'd share in case you decide you no longer want that plugin dependency. You may or may not be familiar with the following...

If you don't want to use multiple tabs (which I avoid), you can background and foreground processes/jobs. ctrl-z (background Vim), run test command, $ fg (brings Vim back to the foreground). I've used this for years.

Where vim-test shines for me is testing within the same test-file with :TestNearest as I don't have to visually find the test number or name and append it as a suffix to the test command and filepath. I didn't bother memorizing the key-bindings as hitting the tab key after :test (defaults to TestFile), :testn (nearest), and :tests (suite) works well enough for me.

Lastly, the bottom of your article shows ctrlp being the next topic up. Curious about whether you're familiar with fzf. I switched away from ctrlp years ago, because it's faster, more featureful (inline/in-project search and preview when coupled with ripgrep or ag) and it's a helluva utility for command-line use. A lot of us do a combination of ls and cd before arriving at the directory containing the project or file we want to open with Vim, but with fzf, you can simply do $ vim ** (followed by a tab) and it'll begin fuzzy searching your entire file system from the current directory. The ** bash-completion globbing from fzf can be prefixed with pretty much any Unix utility, like $ cd **/$ cd foo/bar/** (to anchor the search from a specific directory). I also use $ rg --files | fzf to find a file in the current working directory that contains many files.

Happy programming!

Collapse
 
mblayman profile image
Matt Layman

Those are great thoughts, David! I've heard of fzf and gone back and forth about whether to use it or not. Ultimately, I've found a happy combination with CtrlP which works for me.

That ** technique sounds pretty cool so I'll have to give that a try in the future.

For context, I wrote this series initially in 2017 so I've had some time to think about my choices. I periodically go back and upgrade various plugins (like ag to rg) when I have a weekend to burn.