When you search multiple files in Vim, it’s really just grepping under the covers. Grep was first published in 1984, and it’s pretty much guaranteed to be included on any Unix box you might find yourself on. Grep is a Unix command that lets you search through multiple files for a pattern. For this post, the “heavy lifting” we’re talking about is sifting through lots of files for a pattern, and the “proper utility” we’re talking about is grep. When Vim needs to do something outside of its responsibilities, it outsources that heavy lifting to the proper utility and then jumps back to what it does best: editing text. Write programs to work together.” Vim edits text. Vim follows the tried-and-true Unix philosophy of “Write programs that do one thing and do it well. Let’s start by taking a couple steps back and looking at why things work this way. In this post, we’ll explore searching through multiple files in vanilla Vim. Searching through multiple files should be convenient, not scary. I’d end up walking away with results, yet feeling like I didn’t do it quite right. “Is this pattern I’m typing interpreted as a regex, or a literal string? Do I need quotes? Am I searching through files starting from my current directory or from the directory of the file I’m currently editing? Should it be taking this long? How does :grep differ from :vimgrep or :lgrep or even grep in the command line? Am I really finding every instance of what I’m looking for? And why’s this so difficult in Vim but so easy in every other decent text editor?” I’ve known how to do it, but it rarely proves to be a comfortable experience. My confidence has always been a little shaky when it comes time to search through multiple files for a word in Vim.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |