Sunday, July 17, 2016

Re: how to map the n to nzz just in the jump in search result ?

2016-07-17 18:55 GMT+03:00 Bee <beeyawned@gmail.com>:
> On Sunday, July 17, 2016 at 7:28:48 AM UTC-7, ZyX wrote:
>> 2016-07-17 16:54 GMT+03:00 Bee <beeyawned@gmail.com>:
>> > On Sunday, July 17, 2016 at 5:03:00 AM UTC-7, Tim Chase wrote:
>> >> On 2016-07-16 23:56, Arun wrote:
>> >> > On Sat, Jul 16, 2016 at 4:52 AM, Tim Chase
>> >> > > :nnoremap n nzz
>> >> >
>> >> > As it appears that the intent here is to re-center the searched
>> >> > line, another approach is to set a high 'scrolloff' lines, like
>> >> >
>> >> > :set scrolloff=999
>> >> >
>> >> > That way, even backward search (or any other jump for that matter)
>> >> > would also re-center the screen.
>> >>
>> >> Yeah, I wondered that, but it's one of those things that I find is
>> >> nice in certain instances, but drives me nuts if it's on all the
>> >> time. Other such things are 'hls' and having all yanks/deletions go
>> >> to my system clipboard. I find that being intentional in the couple
>> >> cases where I do want such features annoys me far less than having
>> >> them on all the time.
>> >>
>> >> But if the OP wants the cursor centered all the time, that's
>> >> definitely the way to go.
>> >>
>> >> -tim
>> >
>> > No need to have it on always:
>> >
>> > function! Scoff()
>> > let &scrolloff = &scrolloff==1 ? 555 : 1
>> > endfun
>> > nmap <special> <silent> <F6> :call Scoff()<cr>
>> > imap <special> <silent> <F6> <c-o>:call Scoff()<cr>
>>
>> You must not use *map without nore unless you have a clear explanation
>> why you prefer them. I.e. nnoremap and inoremap should be the default
>> always.
>>
>> This best practice avoids issues like OP has. Your mappings are a
>> source of the problem if e.g. a user has not too uncommon `noremap :
>> ;`+`noremap ; :` mappings that swap : and ;.
>>
>> >
>> > Bill
>> >
>> > --
>> > --
>> > 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 vim_use+unsubscribe@googlegroups.com.
>> > For more options, visit https://groups.google.com/d/optout.
>
> Do I understand correctly?
> Always use nnoremap or inoremap
> Unless recursion is desired

Yes. I additionally suggest that "recursion is desired" should be read
as "every single key in {rhs} is being remapped" if you are writing a
plugin: this leaves only mappings like `nmap default
<Plug>(MyFooPluginMapping)` which is somewhere preceded by something
like `nnoremap <Plug>(MyFooPluginMapping) :<C-u>call
myfooplugin#function()<CR>`, so the whole {rhs} is being remapped to
something else. But this is too strict if you are writing something
for your vimrc.

>
> --
> --
> 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 vim_use+unsubscribe@googlegroups.com.
> 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 vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments: