bind v to open file in $EDITOR
mundry opened this issue ยท 4 comments
Hi there,
first of all: Great job! I've really been enjoying moar
so far.
Something that's ingrained in my muscle memory from less
is pressing v
to open the current file in $EDITOR
.
It would be great to have that same functionality in moar
, too.
What do you think?
I want this. It would sort of solve #135 as well.
For reference I tried less
's behavior (less 581.2
, comes with macOS) and:
- With
$EDITOR
set:- When showing an actual file,
less
does/usr/local/bin/fish -c code -w +34 services
and waits for that command to finish. Parts are:/usr/local/bin/fish
is my shell-c
tells the shell to execute a command linecode -w
is my$EDITOR
variable+34
is unknown and messes up the editor. It's not the current line number at least since I'm on the first line inless
.services
is the file I opened.
- When piping from
stdin
,less
just says "Cannot edit standard input"
- When showing an actual file,
- With
$VISUAL
set (and not$EDITOR
)less
does the same thing, but uses the value of$VISUAL
instead. - If the editor doesn't exist, nothing happens on
v
, but error messages are shown after exitingless
.
Except for the number I think this makes for a reasonable starting point.
less
primarily picks $VISUAL
, then falls back to $EDITOR
, then to vi
(from defines.ds
):
https://github.com/gwsw/less/blob/db13e771320d4bfc9d403ee951b623a8c3d5e425/main.c#L331-L342
FYI, with v1.24.4 this now works when piping input to moar
as well.
I know I have wanted that, maybe you do as well :).