1

I have below mapping in .vimrc.

nmap gb <C-^>

What I want to do is open a directory, gf to a file, then gb go back to previous directory.

But sometime gb is not working properly. It goes back to another text file instead of previous directory.

1
  • Seems if it's a normal file, gb can go back, but not for a directory, need to figure out how to jump back to a directory.
    – Fisher
    Nov 24 '17 at 14:51
2

The problem is netrw, the plugin which allows vim to browse directories, overrides the gb map for its bookmarks feature.

You can disable this by providing a junk mapping in your vimrc:

nmap <sid>NetrwBookHistHandler_gb <Plug>NetrwBookHistHandler_gb

Or use any left hand side

nmap <silent> <f4> <Plug>NetrwBookHistHandler_gb

Also, you don't need to use gf to go to a file inside a directory. Pressing enter works too.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.