How to use Ranger as file explorer for Vim

Vim has an internal file explorer called NetRW. Another popular choice of file explorer for Vim is the NERDTree plugin. Recently, I started to use Ranger as my file explorer at the shell. I could open text files in it using Vim easily. However, what I really wished was to use Ranger from inside Vim as a file explorer.

Using Ranger inside Vim allows me to keep a Vim session with many files open and fall down to Ranger to explore and manipulate files and jump back into my Vim session. Another big advantage is that the files I open using Ranger all persist as buffers in the Vim session. That is, if I am working on File1, I jump to Ranger to find File2 and open it, then it should open back in the same Vim session, so that I now have File1 and File2 open. Thankfully, all of this is possible easily! 🙂

To use Ranger as a file explorer for Vim, all you need to is add this code to your Vimrc. You can then launch Ranger whenever you want by pressing your leader key and r. That is, usually it is \r.

Tried with: Ranger 1.6.1, Vim 7.4 and Ubuntu 14.04

3 thoughts on “How to use Ranger as file explorer for Vim

Leave a Reply to jamiemacdo Cancel reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.