When I open a directory in netrw by opening vim like vim .
, it will show me a list of files in the current directory. If I find a file then press t
it will open that file in a new tab, when I'm done, I'll close the file with :q
, then the netrw tab will be shown again but my cursor will be at the top, not over the file I just opened. How do I get it to not move the cursor?
1 Answer
I had to add the following line in my .vimrc:
let g:netrw_fastbrowse = 2
When that variable is set to 2, it will not refresh the listing every time you enter the buffer, and so it will not position your cursor at the top of the screen.
Extra info:
I found within netrw there's an autocommand like this:
au BufEnter * sil call s:LocalBrowse(expand("<amatch>"))
not sure what it's trying to do, but if I disable it, makes my cursor stay where I want it to be. So I wrote a file in ~/.vim/after/plugin/netrw.vim with this line:
au! FileExplorer BufEnter
while this works with starting vim like vim .
it doesn't work when running something like :e .
once inside vim. So the better solution is to set the variable above.
8.2.4699
(netrw dates to 9th Feb 2021 according to header) I don't have the issue you describe; instead, the cursor stays on the file.