1

I'm on windows 10 with the Windows subsystem for linux. What I'd like to do with netrw is be able to jump from my home folder in Ubuntu to my home folder in windows. In Ranger I type gh and it takes me to my Ubuntu home folder immediately. I mapped ga to go to my Windows home folder so I can jump to that folder immediately too. Can this be done with vim's netrw without any plugins? I want a shortcut to jump between these two directories:

  • Ubuntu home directory: /home/me
  • Windows home directory: /mnt/c:/users/me

2 Answers 2

4

Netrw supports bookmarks, which could be used for this. See :h netwr-bookmark:

BOOKMARKING A DIRECTORY netrw-mb netrw-bookmark netrw-bookmarks One may easily "bookmark" the currently browsed directory by using mb [...] netrw-:NetrwMB Addtionally, one may use :NetrwMB to bookmark files or directories. :NetrwMB[!] [files/directories] 
CHANGING TO A BOOKMARKED DIRECTORY netrw-gb To change directory back to a bookmarked directory, use {cnt}gb 
LISTING BOOKMARKS AND HISTORY netrw-qb netrw-listbookmark Pressing "qb" (query bookmarks) will list both the bookmarked directories and directory traversal history. 

So, you can run :NetrwMB /mnt/c:/users/me/ to add it as a bookmark. Use qb to see the list of bookmarks, and note the number (which should be 1 if you haven't added a bookmark yet), and press <number>gb (e.g., 1gb) to go that directory.

Note that the list of bookmarks is kept in a sorted order (not by order of addition). So if you bookmark more directories, the numbers may change.

1
  • Thanks for the clarification. I added the following to my notes for quick reference: mb to bookmark current directory qb to query bookmarks 1gb to goto bookmark1 2gb to goto bookmark2 bc to close bookmarks Commented Jun 8, 2019 at 14:48
2

You can

bookmark current Directory using

mb 

then go to that direct

gb 

or if you have several bookmark

{number}gb (ex - 1gb, 2gb, 3gb) 

to see the list of bookmark

qb 

to delete bookmark (notice that B is uppercase)

{number}mB 

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.