On Mar 11, 2014 11:33 AM, "Paul Isambert" <[email protected]> wrote:
>
> Hello Ethan,
>
> Ethan Hereth <[email protected]> a écrit:
> > I have a question that I think should have a better answer.
> >
> > I used to have a couple normal mode maps in my .vimrc that went like
this:
> >
> > nnoremap n nzz
> > nnoremap N Nzz
> >
> > which, as I'm sure I don't need to tell most of you, causes the next
search result to be centered (usually) when the user presses n/N. These
maps worked great for a long time... Until I installed the IndexedSearch
plugin, which I do really like by the way. This broke my maps which annoyed
me for quite some time until today when I decided to track down the cause.
> >
> > Typing 'verbose map n' gave me the following:
> >
> > n n * :let v:errmsg=''<CR>:silent! norm! n<CR>:call
<SNR>34_ShowCurrentSearchIndex(0,'!')<CR>
> > Last set from ~/.vim/bundle/IndexedSearch/plugin/IndexedSearch.vim
> >
> > So now I see that the IndexedSearch plugin has stolen my maps. So, for
now I have changed the appropriate lines in the IndexedSearch.vim plugin as
follows to get back the previous behavior without losing IndexedSearch's
addition. So, I'm happy now.
> >
> > nnoremap <silent>n :let v:errmsg=''<cr>:silent! norm! nzz<cr>:call
<SID>ShowCurrentSearchIndex(0,'!')<cr>
> > nnoremap <silent>N :let v:errmsg=''<cr>:silent! norm! Nzz<cr>:call
<SID>ShowCurrentSearchIndex(0,'!')<cr>
> >
> > My question is: Is there a better way to do this? Instead of actually
modifying the plugin code I'd like to simply modify the map after
IndexedSearch has set it. I did skim both Google and ':help map' but
nothing popped out at me as answering my question.
>
> Add a plugin in your "after" directory, e.g.:
>
>     " Beware, no 'noremap' this time!
>     nmap n nzz
>     nmap N Nzz
>
> in "$HOME/.vim/after/plugin/IndexedSearch.vim" (replace ".vim" with
> "vimfiles" if you're on Windows). Files in "after" are loaded, well,
> after anything else.

If there is no z or zz mapping this variant is not different from

    nnoremap n nzz
    nnoremap N Nzz

. You just suggest to disable plugin mapping. The only reason why this
works is because when mapping rhs starts with lhs this part is not remapped.

Files in .vim/after/ directory are loaded just like files in .vim/. Just in
default &runtimepath option .vim/after/ directory is placed after all other
directories, but there nothing else special about it. Plugins like
pathogen/VAM/Vundle usually put other plugin's after/ (but not root)
directories after .vim/after so "after anything else" statement is no
longer true. It is not very common though for plugins to have after/
directories.

>
> Best,
> Paul
>
> --
> --
> You received this message from the "vim_use" maillist.
> Do not top-post! Type your reply below the text you are replying to.
> For more information, visit http://www.vim.org/maillist.php
>
> ---
> You received this message because you are subscribed to the Google Groups
"vim_use" group.
> To unsubscribe from this group and stop receiving emails from it, send an
email to [email protected].
> For more options, visit https://groups.google.com/d/optout.

-- 
-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to