So I've created some helper functions to help work around netrw. They are some keybind simplifications that help with things like window/cursor management when opening files, where to open them, handing marked files, closing netrw when done etc.
I map them with the following in my vimrc:
augroup NetrwGroup autocmd! autocmd filetype netrw call NetrwMapping() augroup END
function! NetrwMapping() setl bufhidden=wipe | setl modifiable nmap <buffer>x mf nmap <buffer>. cd nmap <buffer>C :NetrwTouch<CR> nmap <buffer>D :NetrwDelete<CR> nmap <buffer>h o nmap <silent> <buffer>T :call NetrwOpenInTabs()<CR> nmap <silent> <buffer>W :call NetrwOpenInWindows()<CR> nmap <silent> <buffer>B :call NetrwOpenInBuffers()<CR> " remap refresh to <c-r>, to free up <c-l>, so that it doesn't overwrite my window navigation mapping nunmap <buffer><C-r> nmap <buffer><C-r> <Plug>NetrwRefresh nmap <buffer><C-l> <C-w><Right> endfunction
Now, what I'm trying to add is an alternate to
normal v mapping. I know that normally
v is mapped to
<SNR>76_NetrwSplit(5)<CR>). I'd like to be able to call that in my function and then do some additional things. So the mapping would be:
nmap <buffer>v :call NetrwOpenVirtSplit()<CR>
and a simple example of my function:
function! NetrwOpenVirtSplit() normal v " some other stuff " move the cursor " close netrw etc. endfunction
So if that's an easy fix, I'd like to do that and go about my life.
Alternatively, and more complicatedly, I've looked into calling
<SNR>76_NetrwSplit(5) directly, but I can't quite figure out the name spacing situation. This worked for example:
nmap <buffer>v :call <SNR>76_NetrwSplit(5)<CR>
But I know that the
<SNR>76_ part depends on the script ordering and is subject to change and could break etc. I've tried to dynamically compute it via the
s:SID() function mentioned in the
:h <SID> help but don't know where to put it or how to use it. Plus, I can't really easily add additional functionality to that in an easy way like I do with the other mappings.
Note: regarding namespacing, all the above mappings/function definitions are in my vimrc and
<SID>NetrwSplit() is in