vim-unimpaired icon indicating copy to clipboard operation
vim-unimpaired copied to clipboard

repeat buffer next/previous with holding [ or ]

Open AntoineD opened this issue 12 years ago • 9 comments

I'd like to repeat next buffer (]b), for instance, by holding ] and pressing b several times without having to press the full combo ]b more than once, is it possible?

AntoineD avatar Sep 17 '13 08:09 AntoineD

Not really viable; Vim doesn't have any mechanism for distinguishing between keydown/keyup; when you hold the key, you'll just be sending the key repeatedly to vim (on most systems).

qstrahl avatar Sep 17 '13 14:09 qstrahl

What do you mean by "not really viable"? The builtin :tabnext is mapped to C-PageDown and has the behavior I'm looking for: I hold C and press several times PageDown for moving to the next tabs.

AntoineD avatar Sep 18 '13 07:09 AntoineD

Ctrl is a modifier key; [ and ] are not. Getting Vim to treat [ and ] as though they were modifier keys would probably involve a ludicrous amount of hackish code and break a lot of things -- if it's possible at all.

qstrahl avatar Sep 18 '13 13:09 qstrahl

Hey @AntoineD, I recently started fooling around with a little plugin that basically provides what you want. Haven't really written any documentation for it, but buffer handling looks like this:

  • Hit a special prefix-key (currently defaults to <esc>, though I tend to use <space> myself right now) and b to enter a special mode where some keys have different functionality related to buffer handling
  • Hit j to get to the next buffer, k to get to the previous buffer, w to save the current buffer, q to close it (like hitting :bd), x to write and close it. No need to hold any keys, jumping around buffers is located on the home row and some of the most likely next actions are directly available through hitting one more key. Best thing is that you only have to give up one mapping (prefix + b) and don't have to waste valuable keyboard space.
  • Any other key is working as usual and leaves the special mode again.

There are only a few other features implemented right now, but more to come! Check it out: https://github.com/LFDM/vim-hopper

LFDM avatar Feb 14 '14 17:02 LFDM

@AntoineD, what if unimpaired were to use , and ; to repeat its motion commands?

Personally, I think I would love this. ]q;; would go to the third error in the quickfix window. Sure, 3]q works, but it assumes I already know which error I want to go to. Often I need to look through them to understand what's going on.

To scan forward and backward through a bunch of search results, ]q;;,,;;,;,,,. That's a lot easier to type than ]q]q]q[q[q]q]q[q]q]q]q]q!

Not sure if Vim's internals would allow it though.

bronson avatar Jun 16 '14 19:06 bronson

@bronson, that is exactly what I use my vim-hopper for. I type <space>q to go into quickfix mode and then j and k to cycle through it (apart from some other things that mode provides then).

LFDM avatar Jun 16 '14 20:06 LFDM

@bronson That's great idea. Hope one day it gets implemented.

amosbird avatar Oct 13 '15 14:10 amosbird

I do kinda like the ;/, idea but that's a pretty invasive thing to experiment with this late in the game.

tpope avatar Oct 13 '15 20:10 tpope

@bronson repeatable-motions.vim is supposed to do that (with different default keys). I created a fork that works with unimpaired: https://github.com/jkuan/repeatable-motions.vim/tree/unimpaired_support

jkuan avatar Nov 24 '17 04:11 jkuan