Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to increment in vim under windows (where CTRL-A does not work...)

Tags:

While CtrlX works fine in vim under windows, CtrlA selects all (duh).

Is there a way to increment a number with a keystroke under windows?

like image 277
Paul Oyster Avatar asked Sep 15 '08 21:09

Paul Oyster


People also ask

How to Ctrl a in vim?

If you use Vim under screen , press Ctrl-A and then hit a . Screen then sends on a translation of Ctrl-A to the underlying program, Vim.


1 Answers

You can make CtrlA to 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 CtrlA keystroke will increment.

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

like image 152
TMealy Avatar answered Oct 27 '22 00:10

TMealy