something I find myself doing quite often is the above, i.e. I have:

extract(p,f,m,n)

and I want

extract(p, f, m, n)

Well, if you just want to normalize all commas on the current line to have a single space after them, you could do something like

        :s/,\s*/, /g

which can be mapped, as in

        :nnoremap <f4> :s/,\s*/, /g<cr>

(typed literally, with all greater-than and less-than signs).

This scales nicely to re-comma-ing your entire document with

        :%s/,\s*/, /g

in one pass.

and rather than going to the comma and pressing 'a', 'space', 'Esc' I would prefer to use a single key and stay in normal mode, can someone give me a pointer to the place in the help for this, I tried insert, but that is all about insert mode.


If you just want to insert/append a space, you can do something like

        :nnoremap <space> i<space><esc>
        :nnoremap + a<space><esc>

(again, all LT/GT signs are literal)

Arbitrarily choosing the space to insert to the left of the current position, and "+" to insert a space.

Another option would be to insert the space (or other string) once as you see fit, and then use the period command to repeat the last action. Thus, you move to the first comma, append your space once, and then move to the next comma and hit the period to repeat the action.

You can learn more at

        :help map
        :help .


Hope this gives you some ammo to attack your problem.

-tim



Reply via email to