Tuesday, May 31, 2011

Re: collision

Reply to message «<leader> collision»,
sent 18:12:20 31 May 2011, Tuesday
by Steven Lee:

> In my .vimrc, I attempt to map ",,d" to a function call, see below:
>
> autocmd FileType markdown nmap <silent> ,,d :call <Sid>InsertMkdDate()<CR>
>
> But press ",,d", prompt E81: Using <SID> not in a script conext
I cannot reproduce this, either with or without altering the mapleader.

I can expect this error when markdown filetype is set, but not when you press
,,d. Does this function work when you call it manually using
:call <SNR>{sid}_InsertMkdDate()
? You can get {sid} value in the output of `scriptnames', if it is your only
vimrc it will be 1, but if system vimrc is sourced before your it may be greater
(I have 29, 1 for /etc/vimrc).

And use nnoremap, not nmap.

>
> The issue might come from mapleader setting, it's let mapleader=',' in
> my .vimrc.
I do not see how can this be related. Try `verbose nmap ,,d` and see whether
your mapping was defined and not overriden by some script. In any case, when you
complain about problems, create a script that will show the problem that should
work with `vim -u NONE'. If it is not a vim bug, then in most cases you will
solve your problem while creating it.

Original message:
> Hi all,
>
> In my .vimrc, I attempt to map ",,d" to a function call, see below:
>
> autocmd FileType markdown nmap <silent> ,,d :call <Sid>InsertMkdDate()<CR>
>
> But press ",,d", prompt E81: Using <SID> not in a script conext
>
> The issue might come from mapleader setting, it's let mapleader=',' in
> my .vimrc.
> Is there any way to resove this issue if I stick to let mapleader=','
> and ,,d to call function?
>
> Thanks,
> Steven.l

No comments: