Edit a File When You Are Viewing It Using more / less Command Pager

www‮uttual.‬ri.com
Edit a File When You Are Viewing It Using more / less Command Pager

If you are viewing a file using the more or less command pager, you can enter edit mode by pressing the v key. This will open the file in the default text editor specified by the EDITOR environment variable.

For example, to edit the file filename using nano as the default editor, you can use the following command:

export EDITOR=nano
less filename

Press the v key while viewing the file in less to open the file in nano. Make the necessary changes and save the file as you would in any text editor.

Alternatively, you can specify the text editor to use when opening the file by passing the -e flag to less. For example:

less -e filename

This will open the file in vi by default, or in the editor specified by the EDITOR environment variable if it is set.

Note: The more command does not support the -e flag, so you will need to use less or set the EDITOR environment variable if you want to edit the file while viewing it with more.

Created Time:2017-10-28 14:02:29  Author:lautturi