This is not the Vim tips wiki
Vim's ‘increment number under cursor’ (ctrl-a) and ‘decrement number under cursor’ (ctrl-x) normal-mode commands are too clever for their own good. Several times today I've put the cursor over a negative number (e.g. -12), and pressed ctrl-a, expecting that to increase its magnitude by one (i.e. to get to -13), but no, Vim spots the minus sign and moves the number closer to +∞ (so I end up with -11). I suppose whichever way around it worked, it'd confuse someone. At least it is advertised (in :he ^A) as working correctly on signed numbers, so I have only myself to blame, but I don't know how long it will take me to catch onto its behaviour.
The other annoyance I find is that I often want to use it when editing lists of TV programme episode names, which are often numbered as in 07x13 for the 13th episode of the 7th series. But when you try to ctrl-a the 07, by default Vim recognises that as an octal number because of its leading zero, and increments it to 010, which in this case is incorrect. At least you can turn that behaviour off using the nrformats option. I rarely enter octal numbers in text files, and never want to increment or decrement them, so it's safe for me to turn it off.
While I'm on the subject of Vim efficiency, I've recently started using ctrl-r (in insert mode) more often. Usually, if I want to copy and paste text from another window (only in Windows, or when using Iceweasel, as otherwise I generally select-and-middle-click), I will issue <Esc>"+pa to leave insert mode, paste from the clipboard, then get back into insert mode. But <CTRL-r>+ does the same thing in 40% of the keystrokes. In fact, in insert mode, ctrl-r followed by the name of any register pastes the contents of that register. It understands the ‘special’ registers too: for example, if you type = instead of a register name, you can enter a Vimscript expression and it will paste the value of the expression. Look in the Vim help for more details.
Oh, if you're wondering about the title of this post, yes, there is a Vim tips wiki. And yes, I did use <CTRL-r>+ to paste that URL. See, it's becoming a habit already.
Last modified: Mon Dec 10 01:50:46 2007
It's so hard to see the Sun with the truth in your eyes.
Comments on This is not the Vim tips wiki | no comments | Post a comment