[vim] "gn" with [count] is useless (#632)

90 views
Skip to first unread message

Justin M. Keyes

unread,
Feb 10, 2016, 12:58:37 PM2/10/16
to vim/vim

"gn" is very useful. But to repeat it, user must press "." over and over. Repeating it with a [count] only applies to the count'th instance, instead of repeating the operation [count] times. This is not how f, t, and / work.

Because the current behavior of "gn" with [count] is not useful, I doubt changing the behavior of "gn" would break any plugins. Can the behavior be changed?


Reply to this email directly or view it on GitHub.

Christian Brabandt

unread,
Feb 10, 2016, 2:32:02 PM2/10/16
to vim/vim

Other opinions?

Jerome Castaneda

unread,
Feb 11, 2016, 1:29:12 PM2/11/16
to vim/vim

How about a command that could repeat single-repeats [count] times? Something like this:

function! s:RepeatSingleRepeat()
    for _ in range(v:count1)
        normal! 1.
    endfor
endfunction

nnoremap <silent> g. :<C-u>call <SID>RepeatSingleRepeat()<CR>

So after cgn, [count]g. would change the next [count] occurrences of @/. Although, [count]g. seems like it would only be useful after cgn.

Ben Fritz

unread,
Feb 11, 2016, 2:16:45 PM2/11/16
to vim_dev, v...@noreply.github.com, reply+00b1d198033b7bba6f1974f552c80b224de4af3...@reply.github.com, vim-dev...@256bit.org
On Wednesday, February 10, 2016 at 11:58:37 AM UTC-6, Justin M. Keyes wrote:
> "gn" is very useful. But to repeat it, user must press "." over and over. Repeating it with a [count] only applies to the count'th instance, instead of repeating the operation [count] times. This is not how f, t, and / work.
>
>
> Because the current behavior of "gn" with [count] is not useful, I doubt changing the behavior of "gn" would break any plugins. Can the behavior be changed?
>
>

I thought you were saying "3cgn" or "c3gn" would only edit the third occurrence, which I could see being useful and not necessarily surprising.

But then I experimented and you're saying "3." doesn't do the same thing as "...".

I agree that's unexpected and not very useful. But it's actually consistent with things like ">>". For example, ">>2." does not do what I'd expect, either; I need to do ">>..".

Justin M. Keyes

unread,
Feb 11, 2016, 2:27:14 PM2/11/16
to vim...@googlegroups.com, reply+00b1d198033b7bba6f1974f552c80b224de4af3...@reply.github.com, vim-dev ML, v...@noreply.github.com


On Feb 11, 2016 2:16 PM, "Ben Fritz" <fritzo...@gmail.com> wrote:
>
> On Wednesday, February 10, 2016 at 11:58:37 AM UTC-6, Justin M. Keyes wrote:
> > "gn" is very useful. But to repeat it, user must press "." over and over. Repeating it with a [count] only applies to the count'th instance, instead of repeating the operation [count] times. This is not how f, t, and / work.
> >
> >
> > Because the current behavior of "gn" with [count] is not useful, I doubt changing the behavior of "gn" would break any plugins. Can the behavior be changed?
> >
> >
>
> I thought you were saying "3cgn" or "c3gn" would only edit the third occurrence, which I could see being useful and not necessarily surprising.

"I could see it being useful" applies to almost anything and adds no information.
Have you ever used 3cgn intentionally, and been glad that the alternative behavior is not implemented instead?

The major use case of gn is to apply an operation in batches. Why insist on a default behavior which stymies that?

---

Justin M. Keyes

Justin M. Keyes

unread,
Feb 11, 2016, 2:33:02 PM2/11/16
to vim...@googlegroups.com, reply+00b1d198e658f7a95508391936d2adbe23f4880...@reply.github.com, vim/vim


On Feb 11, 2016 1:29 PM, "Jerome Castaneda" <vim-dev...@256bit.org> wrote:
>
> How about a command that could repeat single-repeats [count] times? Something like this:

I can do all kinds of things with mappings. I am proposing improving user experience for *all* users. Not the emacs way of building a private nest full of twigs and yarn.

Björn Linse

unread,
Feb 11, 2016, 3:07:53 PM2/11/16
to vim/vim, vim-dev ML

speaking of >> I was always annoyed that 2>> and >2> mean exactly the same thing, when more usefully the first could mean repeat and the second line count (or vise versa, but I like to think of the second > as the motion) Not sure how well this applies to 2cgn vs c2gn because I haven't used it.

Ben Fritz

unread,
Feb 11, 2016, 4:20:59 PM2/11/16
to vim_dev, reply+00b1d198033b7bba6f1974f552c80b224de4af3...@reply.github.com, vim-dev...@256bit.org, v...@noreply.github.com

If the interface was perfect for me, I'd expect "3cgn" to change the next 3 matches, and "c3gn" to change the 3rd match only, because that's something I'd do on purpose from time to time.

But to answer your question, no, I didn't realize [count]gn worked this way, especially when combined with the '.' repeat operator, so I've never done that on purpose so far.

Reply all
Reply to author
Forward
0 new messages