Wednesday, January 27, 2010

Re: ctrl-j mapping not working properly

On Wed, Jan 27, 2010 at 8:12 AM, Mr.SpOOn wrote:
> Charles Campbell:
>>I suggest that you use
>>
>>nn <c-j> <c-w>j
>>
>>so that you don't get remapped, and keep the mapping active only in normal mode.
>
> I don't really get the 'nnoremap' command.
>
> I mean, I know it's useful in this situation:
>
> :nnoreamp x y
> :nnoremap y x
>
> So that it doesn't loop between x and y. Is that right?

Yep.

> But in my case?

The noremap'ing versions should be what you use by default. In your
case, your map will do the wrong thing if a plugin has :nmap'ed <C-w>
or j or <C-w>j - all of which would be really odd things for a script
to do, but it could happen. By using the noremap'ing version, you
know what your map will do - it will switch to the window below the
current one. If you don't use the noremap'ing version, your map will
do either that, or something different, depending on the presence or
absence of other maps.

Because of all that, it's advisable to always use the noremap'ing
variants by default, and to only use the remap'ing varieties when you
explicitly want that extra layer of indirection.

~Matt

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

No comments: