<a href="http://www.cyberciti.biz/faq/edit-file-when-youre-viewing-withmore-less/">Aritcle here.
<a title="Permanent Link to Edit a File When You Are Viewing It Using more / less Command" rel="bookmark" href="http://www.cyberciti.biz/faq/edit-file-when-youre-viewing-withmore-less/">Edit a File When You Are Viewing It Using more / less Command<div style="color: #888888;">Posted by Vivek Gite [Last updated: November 1, 2008]
<div id="EchoTopic"> <div style="float: left; margin-top: 0px; margin-right: 5px;">
<div style="float: right; margin-top: 0px; margin-left: 5px;"><a title="See all Bash/Shell scripting related FAQ" href="http://www.cyberciti.biz/faq/category/bash-shell/"><img src="http://blog.amit-agarwal.com/wp-content/uploads/figs.cyberciti.biz/3rdparty/terminal.png" border="0" alt="" />
<span style="color: #ff0000;">Question: I can use <a href="http://www.cyberciti.biz/tips/less-is-more-the-hidden-treasure-of-less-command.html">less or more pagers to view a file. How do I start an editor (such as vi or other text editor) to edit the current file without leaving the less or more pager command?
<span style="color: #009900;">Answer: You can always start up an editor immediately to edit the current file being viewed. This will save some time and command typing. 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. I suggest you define your EDITOR first, enter:
1
|
<td>
<div class="text codecolorer">
$ export EDITOR=vim
</div>
</td>
</tr>
OR
1
|
<td>
<div class="text codecolorer">
$ echo \'export EDITOR=vim\' >> ~/.bash_profile
</div>
</td>
</tr>
Now open any file using more or less pager:
1
|
<td>
<div class="text codecolorer">
$ less myfile.txt
</div>
</td>
</tr>
OR
1
|
<td>
<div class="text codecolorer">
$ more ~/some.conf
</div>
</td>
</tr>
Now, to edit a file, hit <span style="color: #0000ff;">v key from keyboard. This will start up an editor at current line and file.