Tuesday, February 17, 2015

Re: vim: least key stroke to replace a word

Hi,

On Tue, Feb 17, 2015 at 7:18 PM, ping song <songpingemail@gmail.com> wrote:
> experts:
> I know this looks stupid and simple, but I don't know the answer right now.
>
> say I want to replace a word :
>
> from:
>
> abc 456
>
> to:
> 123456
>
> what I did is:
> 1. put my cursor in a, then cw123<esc>x , 7 strokes
> 2. put my cursor in b, then caw123<esc>, 7strokes
> 3. put my cursor in a, then dwi123<esc>, 7 strokes
>
> it looks cw and dw behaves non-consistently, which I know is by the design.
>
> I'm editing an old doc full of typos and spelling errors, etc, and I
> need to do this quite often, does anyone knows of a
> least-strokes-method (to protect my fingers) ?

If it's always this kind of replacement you have to do, you could
maybe map a single key that you do not usually use in normal mode, for
example :

:nnoremap X dwi

That way you'd get it down to 5 keystrokes, cursor on 'a' and then X123<Esc>

(this made me learn about the 'normal' function of X, cool :) )

Or you could get it down to 6 in this case: cursor on '4' and cb123<Esc>

nico

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments: