Overview
Vim is my editor of choice, mostly because I like how it looks, I like being able to solely use the keyboard and, after some practice, the commands are pretty intuitive and easy to learn. However, one major thing I need to do often in order to be effective at my job is to grep for variables and functions to follow the code's flow. But vim makes it difficult because it's run in the terminal that you opened it from, so unless you close out of your file you'll have to find other ways of executing the command.
Bad Solution
The bad solution to this is to have multiple terminals, one for code, and one for doing random commands, like grep. The problem with this is this can quickly get very clunky and hard to organize.
Good Solution
The proper solution to this is to issue the command in vim. You can issue any command in the terminal from vim by typing :! then then command. So to execute a grep command from the terminal, type this in your vim file:
:! grep -r "<thing_you_are_searching_for>"
Replacing <thing_you_are_searching_for> with whatever word or phrase you want to replace. You will be taken back to the terminal and shown the results from your search. You can then go back to your vim session by hitting the "Enter" button on your keyboard.
NOTE: This guide is currently in rough draft form and could be improved with clearer instructions and pictures. If you would like it to be more in depth, I will be extremely happy to improve on this, all you need to do is ask in the comments and I will do it asap (I just don't want to spend forever on something no one reads and/or cares about).
No comments :
Post a Comment