I would like to be able to use my mouse to scroll and click on directories to expand them in netrw. I don't want the mouse to be on for any other filetype/buffertype, so that I can still highlight/copy/paste as normal. I tried a couple ways:
- I created a
setlocal mouse=n nnoremap <buffer> <LeftMouse> <LeftMouse> :norm 0 <CR>
But this leaves the mouse on even after I switch windows or close the netrw window. I also tried putting the
netrw.vim script in ~
/.vim/ftdetect/ to see if it makes a difference, but it doesn't.
- I remapped my mouse buttons in my
.vimrcfile to shift-mouse_button hoping this answer would allow me to toggle off mouse only while that button is pressed, but it didn't.
set mouse=n nnoremap <LeftMouse> <S-LeftMouse> nnoremap <RightMouse> <S-RightMouse>
- I also tried including this in my
.vimrc, on top of what I wrote above in (1):
function! TurnOffMouse() set mouse= endfunction` noremap <LeftMouse> :call TurnOffMouse() <CR><LeftMouse> noremap <RightMouse> :call TurnOffMouse() <CR><RightMouse>
After I use netrw with mouse and switch to a non-netrw window, I have to click the right mouse button twice to get the normal context menu to come up for copy and paste. Is there a way to do it in one click? The left mouse button also doesn't call turn off mouse after the netrw script is loaded.
- This answer uses map-expression and checks filetype, but would doing something like this work (for example only remapping left mouse if filetype == netrw) if mouse isn't set to begin with?
Seems like if mouse isn't set, then it doesn't matter what my custom mouse remappings are, they won't be called.