Carina C. Zona bio photo

Carina C. Zona

Email Twitter LinkedIn

Do you ever do this?

$ less myfile

(View some stuff... Ah-hah, I need to make some changes in this—)

$ editor myfile

Here's a nice shortcut: from within less, hit the 'v' key instead. Voila, file open and read to edit.

man less (OSX 10.6*)

v
Invokes an editor to edit the current file being viewed. The editor is taken from the environment variable VISUAL if defined, or EDITOR if VISUAL is not defined, or defaults to "vi" if neither VISUAL nor EDITOR is defined. See also the discussion of LESSEDIT under the section on PROMPTS below.
LESSEDIT
The default value for LESSEDIT is: %E ?lm+%lm. %f. Note that this expands to the editor name, followed by a + and the line number, followed by the file name. If your editor does not accept the "+linenumber" syntax, or has other differences in invocation syntax, the LESSEDIT variable can be changed to modify this default.

For example, the documentation for TextMate recommends LESSEDIT='mate -l %lm %f'.

The 'v' shortcut only applies when less is reading a file. It's not applicable to reading standard input (STDIN).