Skip to main content
Became Hot Network Question
added 130 characters in body
Source Link
Caleb
  • 2.3k
  • 2
  • 21
  • 35

A plugin I've recently started maintaining currently checks to see if any bindings exist to its functions before creating the default ones. This makes it easy to setup custom bindings and not have to do anything about the default ones.

if !hasmapto('<Plug>MyFunction', 'n')
    nmap <buffer> <Leader>f <Plug>MyFunction
endif

What itthis doesn't do is keep thethese default bindings from clobbering existing mappings. How can I detect if, say, there is an existing normal mode mapping for <leader>f before mappingclobbering it to something (else)with the plugin's default mapping.

A plugin I've recently started maintaining currently checks to see if any bindings exist to its functions before creating the default ones. This makes it easy to setup custom bindings and not have to do anything about the default ones.

What it doesn't do is keep the default bindings from clobbering existing mappings. How can I detect if, say, there is an existing normal mode mapping for <leader>f before mapping it to something (else).

A plugin I've recently started maintaining currently checks to see if any bindings exist to its functions before creating the default ones. This makes it easy to setup custom bindings and not have to do anything about the default ones.

if !hasmapto('<Plug>MyFunction', 'n')
    nmap <buffer> <Leader>f <Plug>MyFunction
endif

What this doesn't do is keep these default bindings from clobbering existing mappings. How can I detect if, say, there is an existing normal mode mapping for <leader>f before clobbering it with the plugin's default mapping.

Source Link
Caleb
  • 2.3k
  • 2
  • 21
  • 35

Detect existing key binding before creating one

A plugin I've recently started maintaining currently checks to see if any bindings exist to its functions before creating the default ones. This makes it easy to setup custom bindings and not have to do anything about the default ones.

What it doesn't do is keep the default bindings from clobbering existing mappings. How can I detect if, say, there is an existing normal mode mapping for <leader>f before mapping it to something (else).