Edit a file when viewing with less / more !!

I use 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.

Here is the trick –
You define your EDITOR first, enter:

export EDITOR=vim
OR
echo ‘export EDITOR=vim’ >> ~/.bash_profile

Now open any file using more or less pager:
less myfile.txt
OR
more ~/some.conf

Now, to edit a file, hit v key from keyboard. This will start up an editor at current line and file. make changes then save and exit, you will be back with less/more pager again 🙂

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: