It’s been a few weeks since I wrote anything about Vim, but that doesn’t mean I haven’t been using it. In fact, it’s all I’m doing my coding in on my laptop, and I’ve got gVim up and running on my desktop to replace Notepad++. There are a number of things I still have yet to get into in Vim, like Vim-style RegEx (this will be a big one, as I use RegEx a lot, and Vim has its own format for them). I’ve made some tweaks to my .vimrc to make things more friendly for me, and even installed a couple of (fairly lightweight) plugins.
As I mentioned earlier, unless you’re actively inputting new text, your time in Vim is best spent in normal mode. The structure of Vim normal mode commands can be pretty intimidating when you have no idea what’s going on with them, but when you break them down, they’re actually pretty straightforward. Basically you just string together commands to accomplish some pretty awesome things. The easiest way to see this is by modifying the movement keys:
j means go down one line, but you can modify that with a number and say
4j to go down 4 lines. You can do the same thing with most other commands;
2dl will delete the next two characters to the right. This would work just as easily with the word-based movement keys;
4wd will delete from wherever you are in the current word and the following three words as well.
What makes this incredibly powerful is the quantity of both movement and operational commands. One of the operational commands I’ve been using the most lately is
c, which is “change”. It deletes text and puts you into insert mode where that text was. On its own, it’s nice enough but no big deal, but when you combine it with the
i[something] selector, you can do some pretty amazing things. The
i means “inner”, and indicates that you’re performing an operation on a group inside of something. You can use
iw for “inner word”, so
ciw will delete the word you’re on and pop you into insert mode so that you can replace it. That’s cool enough, but there are more options:
ci" will change anything within the current quote, and
ci( will do the same with parentheticals. These are great when you’re coding, as you can imagine.
I’m still just learning my way around Vim, and every day it seems like it’s just a little more powerful than I realized. From everything I’ve read, it seems like it takes years to really grasp everything that you can do with Vim, and so far I believe it! I’m looking forward to really getting a grasp on it.