Reputation: 21914
I like Netrw . Its pretty good/poweful and it comes in stock Vim .
However I have a small productivity issue entering into Netrw with the normal Cursor Navigation Mode . The most important activity I do is /
instaed of using the navigable cursor as I know what I would be looking for .
/
i.e search Mode ? I.e Any Netrw buffer defaults to / and hitting Enter
should bring it to the simple Cursor Navigation Mode ? Any ideas how to do this ? Vim is pretty composible and hence this should be possible . Any ideas how to achieve this ? Ofcourse I use CtrlP etc and Netrw has become redundant however its sometimes required to navigate the FS . If you think about its a bit like ido-mode in Emacs , however I was thinking how can I add a layer that uses Netrw but deals with it differently what are the challenges adding that layer and what are some pointers out there to understand these special buffers ?
Upvotes: 0
Views: 896
Reputation: 21914
autocmd FileType netrw call feedkeys("/\<c-u>", 'n')
makes it persistent to the netrw buffer .
Use a mapping like this :
map <silent> <C-E> :call ToggleVExplorer()<CR>
cmap <C-E> <C-\><C-N>:call ToggleVExplorer()<CR>
If you have a toggle function that opens and closes like ToggleVExplorer :
"Toggle Vexplore with Ctrl-E
function! ToggleVExplorer()
if exists("t:expl_buf_num")
let expl_win_num = bufwinnr(t:expl_buf_num)
if expl_win_num != -1
let cur_win_nr = winnr()
exec expl_win_num . 'wincmd w'
close
exec cur_win_nr . 'wincmd w'
unlet t:expl_buf_num
else
unlet t:expl_buf_num
endif
else
exec '1wincmd w'
Vexplore
let t:expl_buf_num = bufnr("%")
endif
endfunction
Upvotes: 0
Reputation: 196456
I would use a crude mapping to deal with your first requirement:
:nnoremap <key> :Explore<CR>/
and see if it really needs more sophistication.
Your second requirement sounds unlikely as that would mean /
is used for two vastly different actions in the same mode which sounds very un-vim-like. <CR>
is clearer and much more intuitive in my opinion.
Vim doesn't do fuzzy search so you'll need to write your own algorithm or lift it from someone else's plugin. set incsearch
might be a good enough interim solution (it sure is, for me).
Upvotes: 1