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?VISUAL=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
.less -X
orLESS=X
appears to do the trick.vim -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?less -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.