How to make ranger open html file in neovim instead of browser?

hello everyone,
whenever i open an html file in Ranger it opens in webBrowser I want It to open in my text editor neovim.
Update : The solution is makes all the html files to open in neovim like from file-explorer too If someone reading wants to configure only ranger do the same just you can try bill_t's suggestion.

edit your ~/.config/mimeapps.list to set your preferred action

I donโ€™t understand what do I have to write in this file.
can you tell me the line to add :sweat_smile:

You can change it when using KDE also with the system setting GUI, in menu Personal Information / Applications / File Associations.

In the direcory ~/.config/ranger/ create a new file called rifle.conf. In this file add this line

ext html = nvim "$@"

Save the file and reopen ranger to see if .html files open in neovim by default.

For more information see the Arch Wiki:


I tried this and the files were opening in neovim from file explorer and ranger.
but then I ran this command ranger --copy-config=rifle as mentioned in ranger arch wiki page .
and then the html files are opening in browser again but only in ranger.
so I decided to add your line :point_down:

even now the files are not opening in broswer
this message showed when I created rifle.conf๐Ÿ‘‡

#  please set the environment variable RANGER_LOAD_DEFAULT_RC to FALSE.

this is all instances of html in my rifle.conf :point_down:

# Websites
# Rarely installed browsers get higher priority; It is assumed that if you
# install a rare browser, you probably use it.  Firefox/konqueror/w3m on the
# other hand are often only installed as fallback browsers.
ext x?html?, has surf,             X, flag f = surf -- file://"$1"
ext x?html?, has vimprobable,      X, flag f = vimprobable -- "$@"
ext x?html?, has vimprobable2,     X, flag f = vimprobable2 -- "$@"
ext x?html?, has qutebrowser,      X, flag f = qutebrowser -- "$@"
ext x?html?, has dwb,              X, flag f = dwb -- "$@"
ext x?html?, has jumanji,          X, flag f = jumanji -- "$@"
ext x?html?, has luakit,           X, flag f = luakit -- "$@"
ext x?html?, has uzbl,             X, flag f = uzbl -- "$@"
ext x?html?, has uzbl-tabbed,      X, flag f = uzbl-tabbed -- "$@"
ext x?html?, has uzbl-browser,     X, flag f = uzbl-browser -- "$@"
ext x?html?, has uzbl-core,        X, flag f = uzbl-core -- "$@"
ext x?html?, has midori,           X, flag f = midori -- "$@"
ext x?html?, has opera,            X, flag f = opera -- "$@"
ext x?html?, has firefox,          X, flag f = firefox -- "$@" ```should I remove this ```
ext x?html?, has seamonkey,        X, flag f = seamonkey -- "$@"
ext x?html?, has iceweasel,        X, flag f = iceweasel -- "$@"
ext x?html?, has chromium-browser, X, flag f = chromium-browser -- "$@"
ext x?html?, has chromium,         X, flag f = chromium -- "$@"
ext x?html?, has google-chrome,    X, flag f = google-chrome -- "$@"
ext x?html?, has epiphany,         X, flag f = epiphany -- "$@"
ext x?html?, has konqueror,        X, flag f = konqueror -- "$@"
ext x?html?, has elinks,            terminal = elinks "$@"
ext x?html?, has links2,            terminal = links2 "$@"
ext x?html?, has links,             terminal = links "$@"
ext x?html?, has lynx,              terminal = lynx -- "$@"
ext x?html?, has w3m,               terminal = w3m "$@"

#html files open in neovim
ext html = nvim "$@"

I just commented out this line and everything is working fine now .

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