jiangmiao / auto-pairs

Vim plugin, insert or delete brackets, parens, quotes in pair
http://www.vim.org/scripts/script.php?script_id=3599
4.09k stars 373 forks source link

g:AutoPairsShortcutToggle limit it in normal mode only #356

Closed pinggit closed 1 year ago

pinggit commented 1 year ago

currently when I set

let g:AutoPairsShortcutToggle = ',aP'

it works in both normal mode and insert mode, when I quickly type ,aP but this will slow down my typing whenever I need to type ,. what I hope is to make it only work in normal mode.

is it possible?

LunarWatcher commented 1 year ago

No, but it doesn't actually slow you down. If you keep typing and don't type ,aP, vim automatically figures out you didn't mean the command and inserts the characters. The visual might be slightly misleading there, but you don't have to wait for the command to time out.

pinggit commented 1 year ago

got it. sounds making sense. I also tried to disable insert mode mapping:

iunmap <buffer> ,aP

it works if I do it after vim started, but if I put it in vimrc it reports errors when vim starts up, says there is no such mapping. I guess I should put it somewhere where vim will read only after everything is up and running...

On Tue, Nov 1, 2022 at 6:35 PM Olivia (Zoe) @.***> wrote:

No, but it doesn't actually slow you down. If you keep typing and don't type ,aP, vim automatically figures out you didn't mean the command and inserts the characters. The visual might be slightly misleading there, but you don't have to wait for the command to time out.

— Reply to this email directly, view it on GitHub https://github.com/jiangmiao/auto-pairs/issues/356#issuecomment-1299313694, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAPRSHD63IKVUJLAZT4V7ZLWGGLKFANCNFSM6AAAAAARUFBFM4 . You are receiving this because you authored the thread.Message ID: @.***>

LunarWatcher commented 1 year ago

Yep, but also no. The map is a buffer mapping, which honestly is a weird decision for a toggle. You can just disable the map and manually create the nmap:

https://github.com/jiangmiao/auto-pairs/blob/master/plugin/auto-pairs.vim#L569-L573

I.e. let g:AutoPairsShortcutToggle = "" and nnoremap <silent> ,aP :call AutoPairsToggle()<CR> in your .vimrc instead.

pinggit commented 1 year ago

works well! thanks.