> Hi,
> Is there a way to make the netrw dir listing maintain
> the cursor position?
> For example if I do a dir listing on a big dir, scroll down,
> and press enter to edit a file, when I go back to the dir
> listing the cursor is no longer at the file where I left it.
> The cursor starts over at the top of the dir listing.
> This is a pain if I want to edit a handful of files chosen
> from the netrw listing.
> Is there a way to maintain the cursor position in the dir
> listing?
charles may know a better way, but indirectly, here's how i
used to do it (i've since stopped using netrw, but the
principle applies)
i've defined shift-F11 as my browser key with
nmap <silent> <S-F11> :call MyExplore('')<CR>
function! MyExplore(s)
if a:s == "t"
call MyExploreT()
return
endif
call CdCurBuf()
let wh = ' ' . escape(expand("%:t"), '.\') . '$'
call Maikallfiles()
call search(wh)
normal zz
endfunction
you could use the same logic replacing 'call Maikallfiles()'
with 'call Explore()' or your netrw invocation of choice --
'e .' is many ppl's favorite
the call to CdCurBuf simply changes current directory to the
directory of the current file -- i finally weaned myself from
setting 'autochdir' -- in this case you won't find the current
file unless the directory is current to it
for completeness here it is:
function! CdCurBuf()
let cwd = getcwd()
let cth = expand("%:p:h")
if cwd ==# cth
echo 'cwd already ' cth
else
execute 'cd '.cth
echo 'cwd changed to ' cth
endif
endfunction
sc
--
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