Making ranger open text with vim - depends on how ranger is opened

I want ranger to open text using vim rather than nano.
I made changes to .zshrc:
export EDITOR=vim
export VISUAL=vim

Now, ranger will open text using vim, when ranger is opened from the CLI.
However, I wanted to run ranger with a keyboard shortcut, so in my .i3/config, I have bindsym $mod + F3 exec terminal -e ranger. When ranger is opened in this way, it will not open text files with vim but with nano. Is there a way to force ranger to use vim instead of nano?

Do the variables return valid when opened that way?

echo $EDITOR

I have a feeling you dont want to use .zshrc (or .bashrc) as variables there wont be applied to sub-shells and the like.
You may wish to use something like .zshenv
And I might also suggest to use full paths like:


I can’t check the variable when I open ranger using the shortcut, since exiting ranger there is no terminal to enter the command.
I tried making .zshenv and setting the variables in there, but that didn’t change anything.
export EDITOR=/usr/bin/vim in /usr/share/zsh/manjaro-zsh-config also doesn’t change the behavior.

If ranger is not respecting environment variables then edit the ~/.config/ranger/rifle.conf file, search EDITOR and replace it with vim for whichever extensions you want.


If you open ranger with a shortcut on your desktop, the zsh environment is not loaded, it just runs the ranger binary.

This is happening because you’re loading the ranger executable standalone instead of from a zsh shell, in which case all your environment variables declared at the start of the zsh session in your .zshrc would be loaded. I don’t know how i3 is configured, but perhaps changing the command of the keybinding to

EDITOR=vim ranger

would work?

Thank you, that worked!

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.