I am using ranger and every time I try to edit an HTML file ranger will open that file with the browser instead of editing it with Vim.
How can I force ranger to edit HTML instead of loading them in my browser?
I am using ranger and every time I try to edit an HTML file ranger will open that file with the browser instead of editing it with Vim.
How can I force ranger to edit HTML instead of loading them in my browser?
You don't need to edit the configuration for this. Just press r and then select your editor.
By default this will be 2 | ${VISUAL:-$EDITOR} -- "$@", so you'd just press 2 and then Enter (assuming that $VISUAL or $EDITOR are set to your preferred editor).
See Krv Perera's answer if you'd like to change the default ("0") program in rifle.conf.
If, like me, you find yourself mostly editing HTML files and rarely running them from ranger, then you can put this line ext x?html? = ${VISUAL:-$EDITOR} -- "$1" on top of all the other rules for websites in your rifle.conf file.
This way ranger will automatically open the file in your editor of choice and if you need to run it in browser you can press r and then select your browser.
Press r
0 | firefox -- "$@"
1 | chromium -- "$@"
2 | google-chrome -- "$@"
3 | w3m "$@"
4 | ${VISUAL:-$EDITOR} -- "$@"
5 | "$PAGER" -- "$@"
6 | xdg-open -- "$@"
8 | mkdir -p -- ${XDG_DATA_DIR:-$HOME/.ranger}/ranger-trash; mv -- "$@" ${XDG_DATA_DIR:-$HOME/.ranger}/ranger-trash
:open_with vim
Instead type a number I typed vim, and it's working.