When you are viewing text files using more/less command, sometimes you would like to edit that particular file directly using vi without going back to shell and fire up another command. You can do that easily by doing the following.
[email protected]$ export EDITOR=vim
[email protected]$ echo 'export EDITOR=vim' >> ~/.bash_profile
~/.bash_profile will be read every time you log into the system. Now open any text file using more or less utility:
[email protected]$ less file.php
[email protected]$ more file.php
I tend to use ‘less’ more often because I can arrow keys ( including vi arrow keys: j and k ) to scroll the page I am viewing, but you can’t do it with ‘more’. Now you can edit the file directly by pressing ‘v’ key from you keyboard, it will bring you to the vi edit at the line you were at on that file. Happy Linux.

Leave a Reply

Your email address will not be published. Required fields are marked *