Code Yarns ‍👨‍💻
Tech BlogPersonal Blog

How to use Ranger as file explorer for Vim

📅 2014-Sep-18 ⬩ ✍️ Ashwin Nanjappa ⬩ 🏷️ file explorer, ranger, vim ⬩ 📚 Archive

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

© 2022 Ashwin Nanjappa • All writing under CC BY-SA license • 🐘📧