Wednesday, December 2, 2009

Re: & xmledit

On 2009-12-02, Tuo Pe wrote:
> --- On Mon, 11/30/09, Gary Johnson <garyjohn@spocom.com> wrote:
> >     map <LocalLeader>X :echo "hello X"<CR>
> >     let maplocalleader = ","
> >     map <LocalLeader>Y :echo "hello Y"<CR>
> >     let maplocalleader = ""
> >     map <LocalLeader>Z :echo "hello Z"<CR>
> >
> > and sourced it.  Both the ":map" command and trying
> > the mappings
> > verified that the left-hand sides of the mappings were as
> > expected:
> >
> >     \X
> >     ,Y
> >     \Z
> >
> > It worked for me; I wonder why it didn't work for Tuo Pe.
>
> For some reason, it didn't work for me. :-(
>
> I have this in my ~/.vim/ftplugin/xml.vim file
>
> [...]
> let maplocalleader = ","
>
> nnoremap <silent> <buffer> <LocalLeader>5 :call <SID>Matches()<Cr>
> vnoremap <silent> <buffer> <LocalLeader>5 <Esc>:call <SID>MatchesVisual()<Cr>
> nnoremap <silent> <buffer> <LocalLeader>% :call <SID>Matches()<Cr>
> vnoremap <silent> <buffer> <LocalLeader>% <Esc>:call <SID>MatchesVisual()<Cr>
> nnoremap <silent> <buffer> <LocalLeader>c :call <SID>Change()<Cr>
> nnoremap <silent> <buffer> <LocalLeader>C :call <SID>ChangeWholeTag()<Cr>
> nnoremap <silent> <buffer> <LocalLeader>d :call <SID>Delete()<Cr>
> [...]
>
> Now when I am editing an xml-file, `\d' works but `,d' doesn't.
>
> Is there something special in "nnoremap" as compared to "map"?

I don't think so.

I don't know what the problem could be. When I lack any insight
into a problem, as now, I start with a minimal configuration and
test case, test it, and work towards the actual configuration that
exhibits the problem. In this case, I'd start with a simple file,
test.vim, with something like this in it:

let maplocalleader = ","
map <LocalLeader>X :echo "hello X"<CR>

Then I'd start vim like this:

vim -N -u NONE

and execute

:so test.vim

followed by typing

,X

to see if that works. If it doesn't, your vim could be old, missing
a feature, or broken, or you've found a bug. If it does work, start
vim like this:

vim

and try again. If it doesn't work, there's something in your
configuration that's affecting that mapping and the next step is to
find out what. If it does work, the next step would be to see if
the test file works as a filetype plugin. That is,

cd ~/.vim/ftplugin
mv xml.vim xml.vim.orig
mv ~/test.vim xml.vim
vim foo.xml

and type

,X

If it doesn't work, we'll cross that bridge when we come to it. If
it does work, then change "map" to "nnoremap", test again. Then add
<buffer> and <silent> modifiers, and test again. The idea is to
change your test xml.vim to your actual xml.vim (now xml.vim.orig)
in steps and see what the difference is that causes the mapping to
fail.

That's not the only approach, but it's what I'd suggest at this
point.

HTH,
Gary


--
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php

No comments: