1

In my neovim setup, I am using Tab to cycle forward and Shift-Tab cycle backward through my open buffers (using bufferline.nvim plugin).

Because in Vim, Tab and Ctrl-I are same, I am not able to find a way out where I could keep Tab for cycling through the buffer and use some other key combination for navigating forward in jump list.

Tab and Shift-Tab are quite intuitive for cycling through the buffers. So, I would like to keep buffer cycling mapping unchanged.

However, I also use "jump to the newer position in the jump list" quite often when navigate in the code. This is by default mapped to Ctrl-I but got overridden because of the remapping of Tab. I would like to keep it mapped to some key combination - may be to Ctrl-p.

Please help me achieve it.

I don't want to tweak my terminal inputs produced by Ctrl i/Tab because that would make my configuration not run on all systems/terminals out of the box.

Currently I use the same configuration on my iTerm (Mac) and Terminator (Ubuntu) and I would like to keep it that way.

If above is not possible - I am open to suggestion for remapping my cycle through buffer mappings but it has to be intuitive. I cannot repeatedly press two keys - as I cycle through tabs a lot - so leader key prefix isn't an option. I am fine with keeping one key pressed (like Ctrl) and use other keys to cycle forward and backward through the buffers. But, all combinations I have tried overrides something meaningful or they don't work. Tried following combinations for cycling forward and backward in open buffers - Ctrl-[ and Ctrl-], Ctrl-8 and Ctrl-9, Ctrl-, and Ctrl-..

Vim jump-motion reference

4
  • 1
    To which action would like to map it? Why nnoremap <C-i> .. is not doing the job? What have tried and what is the result :-) Commented May 6 at 16:01
  • I know basics of mapping keys in neovim using: vim.keymap.set() command. However, there I do need to specify which "action" I would like to map the keys to. I don't the action name associated with the "jump to newer position in the jump list" command. Also, I cannot do a recursive remap because that will not free <C-i> for a different mapping.
    – Lone Wolf
    Commented May 6 at 18:07
  • 2
    I've reworded the question to fully explain my situation.
    – Lone Wolf
    Commented May 6 at 20:13
  • 2
    Much better now. Don't know if it's possible, though. There's a note in :help CTRL-I about modifyOtherKeys.
    – Friedrich
    Commented May 6 at 21:29

1 Answer 1

0

Perhaps non-intuitive: throw away your buffer list navigation mappings. No, really. It’s highly unlikely that you really need to navigate via buffers, flipping through them. Search tools, tags, the various « lists » (arglist, quickfix, etc.), and more will get you where you want to go faster. Plus this frees up the default keys.

With tpope/unimpaired, you’d use ]b and [b. Maybe switch your mappings to those?

Further reading:

6
  • 1
    I'm sorry for posting a confusing question. I've reworded it to make the goal and the situation more clear.
    – Lone Wolf
    Commented May 6 at 20:14
  • (Links to come later.)
    – D. Ben Knoble
    Commented May 6 at 23:30
  • I've been using harpoon to tag the files I need to cycle through quickly. But, I think my mind got used to cycling through buffers like an addict. And yes, I do sometimes just jump across many of those in hope to find the one I need as I end up opening too many buffers. Part of the problem is - some LSPs are only able to find references in open buffers. Having said that, I like the idea of throwing away the cycle buffers altogether. But, before that I'll need a way for LSP find references to work without open buffers.
    – Lone Wolf
    Commented May 7 at 2:38
  • That's… odd… that your LSP can only find references within open buffers. I still recommend using the various "lists" and search tools to focus on where you want to get to.
    – D. Ben Knoble
    Commented May 7 at 20:20
  • lightspeed is really good IMO
    – eyal karni
    Commented May 8 at 2:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.