Saturday, November 22, 2025

Mapping behavior in vim

Hi,
  I've installed git gutter for Vim, and I was hoping to get the navigation working. After a long conversation with ChatGPT, and no working solution, I was hoping to get some help from real vim users with mapping "bracket c" to navigate to the next hunk (using Vim 9.1 on WSL). This is what I tried in my ~/.vimrc

" GitGutter hunk navigation
"Failed attempt 1
nmap ]c <Plug>(GitGutterNextHunk)
nmap [c <Plug>(GitGutterPrevHunk)

"Failed attempt 2
nnoremap ]c <Plug>(GitGutterNextHunk)
nnoremap [c <Plug>(GitGutterPrevHunk)

"Failed attempt 3
autocmd VimEnter * nnoremap ]c <Plug>(GitGutterNextHunk)
autocmd VimEnter * nnoremap [c <Plug>(GitGutterPrevHunk)

If I try ":GitGutterNextHunk", it works just fine. But using the shortcut, the screen displays invisible text at the bottom of the screen. If I continue to type, then hit backspace, it shows:

:<C-U>execute v:count1 . 'GitGutterNextHunk'<CR>

Can someone provide any insight into this quirky vim behavior?

Thanks,
Ven

--
--
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.
To view this discussion visit https://groups.google.com/d/msgid/vim_use/CAEodY644bT0z2F_oOLBf2ZO9Eneu_HXkg3K07nH1tVyhuXGhHA%40mail.gmail.com.

No comments: