6

Is there a way to disable a plugin (or a set of keymaps) on a specific filetype? vim-surround causes a delay in netrw when pressing d to create a new directory.

I'm thinking that this might be possible with an auto command that looks something like this:

autocmd Filetype netrw ...something...

There is an open issue here.

2
  • you can just delete the mapping (or comment it out)
    – elyashiv
    Mar 28, 2015 at 18:42
  • I need the mapping in every other buffer, so commenting it out completely isn't really an option.
    – user489
    Mar 28, 2015 at 18:44

1 Answer 1

5

The surround plugin defines global mappings. Unfortunately, you can only override those with buffer-local ones, but not :unmap them only in the buffer. Temporarily disabling and re-defining the global surround mappings would be possible, but is cumbersome.

I think the best solution would be patching the netrw plugin to add the <nowait> argument to the d mapping (and all other buffer-local plugin mappings). This would fix the timeout issue, and you probably don't need to invoke the other (surround et al.) mappings on a netrw buffer, anyway. Unfortunately, netrw's d mapping invokes a script-local function (:call <SID>NetrwMakeDir("")), so it's difficult to redefine the mapping with an :autocmd FileType netrw; you'd need the <SID> of netrw. So please suggest that enhancement to netrw's author, Chip Campbell; you'll find his address in the script header.

1
  • Thank you for the answer, this makes sense. I've already sent an email to the author, hopefully this can be implemented soon.
    – user489
    Mar 28, 2015 at 20:10

Your Answer

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