tags:

views:

1238

answers:

3

While CTRL-X works fine in vim under windows, CTRL-A selects all (duh). Is there a way to increment a number with a keystroke under windows?

+3  A: 

Try Ctrl-NumPad + ?

(from here)

Peter Boughton
thanks. just to complete the answer, one need to also::noremap <C-kPlus> <C-A>
Paul Oyster
A: 

You can make the Ctrl-A increment in windows by opening up the 'mswin.vim' file in your vim directory and finding the section that looks like:

" CTRL-A is Select all
noremap <C-A> gggH<C-O>G
inoremap <C-A> <C-O>gg<C-O>gH<C-O>G
cnoremap <C-A> <C-C>gggH<C-O>G
onoremap <C-A> <C-C>gggH<C-O>G
snoremap <C-A> <C-C>gggH<C-O>G
xnoremap <C-A> <C-C>ggVG

Comment out all of these lines as follows:

" CTRL-A is Select all
"noremap <C-A> gggH<C-O>G
"inoremap <C-A> <C-O>gg<C-O>gH<C-O>G
"cnoremap <C-A> <C-C>gggH<C-O>G
"onoremap <C-A> <C-C>gggH<C-O>G
"snoremap <C-A> <C-C>gggH<C-O>G
"xnoremap <C-A> <C-C>ggVG

and the Ctrl-A keystroke will increment.

This is a pretty nice option when your keyboard doesn't have a real number pad.

TMealy
+1  A: 

I modified TMealy's solution so that CTRL-A still selects all (I find this useful), while CTRL-I increments (also useful).

noremap <C-I> <C-A>

" CTRL-A is Select all
noremap <C-A> gggH<C-O>G
inoremap <C-A> <C-O>gg<C-O>gH<C-O>G
cnoremap <C-A> <C-C>gggH<C-O>G
onoremap <C-A> <C-C>gggH<C-O>G
snoremap <C-A> <C-C>gggH<C-O>G
xnoremap <C-A> <C-C>ggVG
Paul
but Ctrl-I is for jumping to newer cursor position.
Jichao