do more with vim, apparently.

November 18, 2011

Today I decided to actually try using macros, because there were a lot of repetitive things I needed to accomplish, and I have to kind of say: Oh my god, yes.

<C-a> will increment numbers! Though caveat being, if you precede the numbers with zeros so they “line up” (like 01, 02, 03, etc) it will be fine until you hit 07, at which point it will skip 08 and 09 and go straight to 10. Apparently this is due to Vim assuming the preceding zeros mean you want octal values. :set nrformats=hex will force it to thinking in hex, which will increment properly. Yubin Kim expands on other related topics. But yes. Combining incrementing with macros? Love.

There doesn’t seem to be a way to jump to the character after a “word” in one stroke, which slightly bothers me, though I guess f + <space> is good enough for that, a lot of the time. What I’m really wanting, though, is a way to yank a block of text not including the end character. I end up using this fairly often in code, wanting to delete up-to-but-not-including the semi-colon or quotation mark, but I’m still not finding something that works?

I did, however, finally figure out the format for jumping past the first result using f/F, though, which is good. (And really simple, but I kept trying to do things like f2<char> which didn’t work, so yes. 2f<char>.)

Also played around with replacing words with ones I yanked from elsewhere in the file. I’m not entirely sure why, but yiw/viwp didn’t work for me in my macro, but the cw<C-r>0 one did. Would like to figure out why not, but later.