Friday, April 29, 2011

Re: how to map 2-leftmouse to open file in netw

On 29/04/11 09:09, wei gao wrote:
> 2011/4/28 Ben Fritz <fritzophrenic@gmail.com
> <mailto:fritzophrenic@gmail.com>>
>
>
>
> On Apr 28, 10:09 am, wei gao <njugao...@gmail.com
> <mailto:njugao...@gmail.com>> wrote:
> > Hi,
> >
> > In netw file explorer, the click left mouse on the file/folder
> will open the
> > file/folder. Is there any way to use doube click to open the
> file/folder?
> > Left mouse is usually used to select the file/folder instead of open
> > file/folder.
> >
>
> Two steps:
> 1. in .vimrc, add let g:netrw_mousemaps = 0 " disable single-click to
> open file
> 2. in ~/.vim/after/ftplugin/netrw.vim or similar (mine is in ~/.vim/
> after/ftplugin/netrw_maps.vim), put nmap <buffer> <2-leftmouse> <CR>
>
> Note you must use nmap instead of nnoremap, since you are
> intentionally triggering the <CR> mapping in NetRW.
>


> It works. Thanks a lot.
> But I'm wondering why could you make sure the map only applies to netrw
> plugin? Does this has any affect to other fuctions/pluglins in VIM?
>

That's where two pieces of magic come in:

- Placing that line in ftplugin/netrw.vim means that the mapping will
only be defined when creating a netrw buffer (at its FileType event)
- The <buffer> modifier in the mapping means it will only apply to the
current buffer, other buffers won't see it.

See
:help ftplugin
:help :map-<buffer>

Best regards,
Tony.
--
"It runs like _x_, where _x_ is something unsavory"
-- Prof. Romas Aleliunas, CS 435

--
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

No comments:

Post a Comment