Localizing Mappings
Because our mappings are going to be specific to our plugin, what are some ways in which we can distinguish them from the mappings a user might already have? And I did say that we were going to see how a user could reconfigure our mappings to his own liking. Let’s see that.
Mapping <SID> Functions
Remember those two variables back in Constructing a Statusline, that were using that special scope? That was the script scope, and we were using that for variables—we had s:count and s:settings. We can use the script scope for function definitions, too:
mappings/map.vim | |
| function! s:ColorfulCuteAnimals() |
| let animals = ["Phil", "Tom", "Barb", "Bob", "Stacy", "Peary", "Mark", |
| \ "Michael"] |
| for a in animals ... |
Get The VimL Primer now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.