Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can you have different localleaders for different Vim plugins?

I started using a plugin that conflicts with my existing maps, but instead of remapping all of it's maps, I just want to add a prefix. I thought I'd be able to do this with LocalLeader.

Vimdoc says:

<LocalLeader> is just like <Leader>, except that it uses "maplocalleader" instead of "mapleader". <LocalLeader> is to be used for mappings which are local to a buffer.

It seems that the only way to set localleader is to set a global variable (the docs don't mention this, but b:maplocalleader didn't work):

let maplocalleader = '\\'

And I don't see how I'd cleanly unset that variable (an autocmd that clears it after plugins are setup!?)

Is there a way to do this? Or is LocalLeader only to give one global prefix and one filetype-specific prefix?

like image 872
idbrii Avatar asked Aug 22 '12 15:08

idbrii


1 Answers

Your last hunch is correct. If the plugin uses <Leader> (and it should unless it's a filetype plugin), there's no use in messing with maplocalleader.

Remapping is canonically done via <Plug> mappings, which the plugin hopefully offers. Some plugins do define a lot of similar mappings, some of those define a g:pluginname_mappingprefix (or so) variable to save you from having to remap all mappings individually. If your plugin doesn't, maybe write a suggestion / patch to the plugin author.

like image 118
Ingo Karkat Avatar answered Sep 30 '22 04:09

Ingo Karkat