fff icon indicating copy to clipboard operation
fff copied to clipboard

How to open a selected file by "less " instead of "vim"

Open ydLiu-HIT opened this issue 5 years ago • 2 comments

Hi, fff is a wonderful tool I think which is easy to use. But When I want to open a selected text file whose sizes may be large than several GBs, it's not easy to open it with vim. So how to change the tools (eg. less) to open a text file?

Thanks.

ydLiu-HIT avatar Dec 23 '19 06:12 ydLiu-HIT

VISUAL is used for opening text files and those without an extension, with EDITOR and then vi as fallbacks. In your bashrc you can set one or both to less, but there is then no way to get to vi/m through fff. less allows you to press 'v' to go to vi/m, but that references the same environment variables and so will just launch itself. What I did is set both to 'editor', and then put the following in an executable file named editor in a folder on my path:

#!/bin/bash
[[ "$(ps -o comm= $PPID)" == "less" ]] && vim "$@" || less "$@"

This will launch less first, then if you press 'v' will switch to vim.

IsaacElenbaas avatar Mar 29 '20 09:03 IsaacElenbaas

Hi! In my fork of fff I added an ability to open with any file (or multiple marked files) with a command provided by you e.g. pressing o and inputting less will open less with file(s) you wanted. Hope it helps.

bogdan-the-great avatar Dec 24 '23 10:12 bogdan-the-great