Ranger is a terminal-based file manager that uses Vim-like keyboard commands. If you're working in a terminal all day, running Sed and Awk commands and using Vim, then you might want a way to manage files without leaving the comforting glow of your amber-on-black screen. There are, of course, the
cd commands, but sometimes you want to "walk through" your system, or maybe you want to mimic a graphical experience without the graphics.
On Linux, you may find Ranger in your Linux distribution's software repository. On Fedora, CentOS, Mageia, and similar:
$ sudo dnf install ranger
For instance, on Debian, Elementary, Linux Mint, and similar:
$ sudo apt install ranger
If you use Vim, then Ranger is the terminal-based file manager for you. Sure, there's the NERDTree plugin for use while in Vim, but Ranger has all the conveniences of a file manager plus the interface conventions of Vim. If you don't know Vim (yet), then Ranger can serve as a nice introduction to the way Vim is operated.
Launch Ranger from a terminal:
Your terminal is now the Ranger interface, and by default, it lists the contents of your current directory.
By default, Ranger uses a three-column layout. From left to right:
List of home directories on your system.
List of directories.
Contents of the selected directory.
The basic interactions with Ranger can be performed with either your arrow keys or with the classic Vim navigation controls of the hjkl keys.
Up or K: Move to the previous item in a list, making it the active selection.
Down or J: Move to the next item in a list, making it the active selection.
Right or L: Move into a directory or open a file.
Left or H: Move to the parent directory.
If all you need to do is search for a file and open it, then you now know as much about Ranger as you need to know.
Of course, managing files is more than just navigating and opening files. The most common file management tasks have single-key shortcuts assigned to them, and you can view a complete list by pressing ? and then K for key bindings.
Select a file
You can select (or "mark," in Ranger terminology) a file or directory three different ways.
First, whatever happens to be highlighted in the Ranger window is considered the active selection. By default, any action you take is performed on your active selection. When you first launch Ranger, the active selection is probably the
Desktop folder, which is usually at the very top of the list in your home directory. If you press the Left arrow, then you move into the
Desktop folder and whatever item is at the top of that list becomes the active selection. This is the keyboard version of clicking on a file or folder in a graphical file manager.
The other way is to mark several files at once. To mark your current selection, press Spacebar. The item you've marked is indented one space and changes color, and your cursor is moved to the next item in the list. You can press Space again to select that item or move to a different item and press Space on it to add to your marked selection. This is the keyboard version of drawing a selection box around several items in a graphical file manager.
The third way is to select all items in a folder. To select everything, press v on your keyboard. To unselect everything, press v again.
Copy a file
To copy (or "yank," in Ranger terminology) your current selection (whether it's a single file or several files), press y y on your keyboard (that's the letter y twice in a row.)
To paste a file that you've copied, navigate to your target directory and press the p key twice in a row.
Move a file
To move a file from one location to another, press d twice in a row. Then move to your target location and press p twice.
In Ranger as in Vim, you can drop out of the normal mode of interaction to enter a command by pressing the : key.
For instance, say you've descended deep into a series of directories and subdirectories, and now you want to get to your
Zombie_Apocalypse folder quickly. Press : and then type
cd ~/Zombie_Apocalypse and press Return. You're instantly taken to the
There are lots of commands to choose from, and you can see them all by pressing ? and then c for commands.
Ranger is a tabbed interface, just like your web browser. To open a new tab, press Ctrl+N. A tab number appears in the top right of the Ranger interface. To move between tabs, press Alt along with the number of the tab you want to switch to.
While the default view of Ranger is hierarchical columns, you can use an alternate view that splits the Ranger interface into two (or more) panels. This is useful for moving files from one directory to another quickly, or for comparing the contents of directories.
To split Ranger's interface, you change the view mode to
multipane. This is done with the command
set. To run a command in Ranger, you press : and then type your command:
:set viewmode multipane
When you split the Ranger interface, you're actually expanding tabs into one view. Instead of columns, you're now looking at two or more distinct single columns.
Instead of moving between these columns with Right and Left arrows (or h and l), you switch between tabs with Alt and a number. For instance, if you have three tabs open as split panes, the left column is Alt+1, the middle is Alt+2, and the right column is Alt+3.
A file manager for Vim users
Ranger is an obvious choice for you if you're a longtime Vim user, or if you just want to immerse yourself in the Vim style of working. The transition from Vim to Ranger and back again is nearly seamless, so fire up your favorite multiplexer and launch Ranger and Vim for easy access.