Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Buffer local mappings in Vim: <buffer> vs. <localleader>

Tags:

vim

One thing interests me. If one were want to map a mapping specific to some buffer, one can go either way
a) do it with

nnoremap <buffer> d dd

b) or with

nnoremap <localleader>d dd

which will effectively, because localleader is specific to that buffer, make that mapping specific to that buffer too.

That in a way, seems like two overlapping ways to do one same thing. Is there a reason for using one way instead of the other? Is one way preffered over the other for some reason maybe?

like image 325
Rook Avatar asked Nov 02 '11 18:11

Rook


1 Answers

As far as I can tell maplocalleader is shared between buffers. This means that your second map would not be specific to a buffer.

Really, if you're defining a map that is specific to a buffer (e.g. the map only pertains to a specific filetype) I believe convention is to use both <buffer> and <localleader>. If you're defining a map that is not specific to a buffer you should just use <leader>.

like image 183
Randy Morris Avatar answered Oct 21 '22 08:10

Randy Morris