I'm trying to switch to a workflow of mainly using less
when I just want to read code and then using v
to switch into an editor when I want to edit the document. This is GNU less on OS X, but I think it generalizes to other systems.
If I set VISUAL
to vim -u NONE
so that vim doesn't read any of its initialization files, or use another editor that starts instantly like nano
or joe
or ne
, then there's no perceptible pause between pressing v
and having the file appear in the editor.
For instance, this works fine:
$ previous-command > foo.txt
$ VISUAL='vim -u NONE' less foo.txt
view file in less
, scroll to interesting line and press v
, file is instantly visible inside vim
.
Just to illustrate the point, here's what happens if we set VISUAL
to sleep 1; vim
.
$ another-previous-command > foo.txt
$ VISUAL='sleep 1; vim -u NONE' less foo.txt
we're now viewing the file, then we press v
to edit it.
The shell session is now visible again for one second and so we see:
$ another-previous-command > foo.txt
$ VISUAL='sleep 1; vim -u NONE' less foo.txt
After the second has passed we see the contents of foo.txt
inside vim.
Just using vim
by itself, without additional command line arguments, reads files and does some initialization work. This takes a fraction of a second, but long enough that the underlying shell session is visible, as in the case with sleep 1; <VIM COMMAND>
.
Is there a way to transfer control from less
to vim
in such a way that the underlying shell session is not visible, even partially?
VISUAL=clear; vim -u NONE
do it? – Jeff Schaller Dec 22 '18 at 02:43VISUAL=clear; vim -u NONE
), then the original terminal session is not visible at all, even briefly. It is still visible if I useVISUAL=clear; vim
. – Greg Nisbet Dec 22 '18 at 02:49less -X
orLESS=X
appears to do the trick. – Greg Nisbet Dec 22 '18 at 02:57vim -u NONE
, although that's getting closer to "what the—"). I'm wondering if maybe vim is taking forever to launch for you, and you're trying to get rid of the waiting. If so... are you aware of the various file browsing inside vim? And also of vimserver? – derobert Dec 22 '18 at 04:57less
was visible was something I didn't expect.vim
takes a tiny fraction of a second to launch, whether I suppress the custom stuff or not. I guess the main thing I'm after is a better understanding of mitigation strategies when console applications "flicker" and I'm using this as an example because it's reproducible. – Greg Nisbet Dec 22 '18 at 05:31less -X
appears to work, but I don't really understand why. What exactly happens whenless
transfers control to an editor (other than passing a+43
-style argument to indicate the line number) is still a bit mysterious. – Greg Nisbet Dec 22 '18 at 05:46