Using VI while Viewing Files In More or Less

Using VI while Viewing Files In More or Less

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.
user@www$ export EDITOR=vim
OR
user@www$ 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:
user@www$ less file.php
OR
user@www$ 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.

Loading

Leave a Reply

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

My new Snowflake Blog is now live. I will not be updating this blog anymore but will continue with new contents in the Snowflake world!