-
Notifications
You must be signed in to change notification settings - Fork 85
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature request: allow launching editor when viewing stdin #70
Comments
I don't quite understand your LESSEDIT setting -- what is $less_stdin_name? In any case, perhaps using a new command for this would work better, as discussed here: |
Sorry for the late reply. The solution you linked almost does what I want, except that would give me a new buffer with the file's contents; I would rather be editing the file itself so that my changes are saved. I didn't explain my example all that well. Here's the exact use-case, where LESSEDIT='%E ?lm+%lm. ?f%f:$less_stdin_filename.'
# E.g.: view filename.c
function view {
less_stdin_filename="$1"
bat "$@" | less -R
} I would use this to view a file, and pressing |
Ok, I see what you're trying to do now. I think using LESSOPEN to preprocess the file would be a better approach. Something like function view {
LESSOPEN='|bat %s' less -R "$1"
} This should allow you to use the v command to edit the original file. |
Perfect! This does exactly what I want, I just had to add One minor question: is there a way to suppress the |
The message cannot be suppressed. It's a warning that what you see in the editor may not match what you were viewing in less, because of the LESSOPEN processing. |
Ok, no worries; thanks again for the help! |
Pressing
v
gives me an editor with the current file and line number. I love this feature, and I'd like to be able to launch an editor this way even when I'm paging through stdin.My use-case is syntax-highlighting via piping the output of another command to
less -R
. This works great, but I lose ability to edit the file withv
. I can almost fix this by setting the filename in an environment variable and customizingLESSEDIT="%E ?lm+%lm. ?f%f:$less_stdin_filename."
. This doesn't quite work, because less stops short of invoking the editor, with the messageCannot edit standard input (press RETURN)
, which is reasonable enough.A possible solution could be to introduce a commandline flag
--launch-editor-stdin
(or--stdin-allow-editor
or something) that turns off this error message. A bit clunky maybe, but if this is a patch you'd accept, I'd be happy to work on it.The text was updated successfully, but these errors were encountered: