Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have the following SQL:

update am.PERMISSIONS set PRM_ORDER = 35 PRM_VISIBLE = b'1' where PRM_ID = 3;
update am.PERMISSIONS set PRM_ORDER = [35] PRM_VISIBLE = b'1' where PRM_ID = 7;
update am.PERMISSIONS set PRM_ORDER = [40] PRM_VISIBLE = b'1' where PRM_ID = 10;
update am.PERMISSIONS set PRM_ORDER = [45] PRM_VISIBLE = b'1' where PRM_ID = 11;

with square brackets I select the visual block, where i want to increase each number by 5. How do I do this?

share|improve this question
up vote 8 down vote accepted

Visually highlight the text in brackets:


Increment each number by five:

:norm 5Ctr+V Ctr+A Explanation:

:norm executes the whole command in normal mode. The Ctr+V is necessary, otherwise the cursor would jump back to the beginning of the line. Ctr+A increases a number by 1, and this is done 5 times. The visual range is inserted automatically after you pressed the colon.

EDIT: As Stephane correctly pointed out, the previous code increments the first number found on any line. Here's a better solution:


It adds five to all integers within brackets. The \zs and \ze are used to exclude the brackets from the match and submatch returns the matched number.

share|improve this answer
It replaces the lines with -VC-A -VC-A -VC-A – J-unior Apr 11 '13 at 10:23
C-VC-A means press ctrl v, release, then press ctrl a, release. – Marco Apr 11 '13 at 10:26
That doesn't apply ^A on the visual selection, but at the start of every line marked by the selection (so for instance, if there were lines with numbers before the selected one, that would increase those and not the selected one) – Stéphane Chazelas Apr 11 '13 at 13:00
You're totally right. It might work for the OPs use case, though. But I agree, my answer is wrong. – Marco Apr 11 '13 at 13:12
This plugin might be of some help to solve the problem, and I believe that if a plugin is necessary to do that kind of operations, it is not a simple matter of finding the right shortcut. – Vincent Nivoliers Apr 11 '13 at 14:56

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.