GagA// 0n D nEt

It is currently Sun May 20, 2018 3:36 pm

All times are UTC




Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: Edit File while using less/more
PostPosted: Sat Nov 01, 2008 7:46 pm 
Offline

Joined: Wed Jul 18, 2007 1:14 am
Posts: 181
Many a times you are viewing a file using less or more command and then you realize that you want to make some changes to it. You then quit the view command and use your preferable editor to edit the file. But you can avoid this by editing the file while you are viewing it.

You can use the hot key v set for less or more.

So if you are viewing the file using less command you can type the v key from your keyboard, which will open the default editor. The default editor for most systems is pico/nano. You can change this editor setting via the environment variables, as the v key uses the environment variable settings for editor.

So you can set the default editor to vim with the following command:
Quote:
[[email protected] ~]# export EDITOR=vim

Or you can make this permanent with the following command:
Quote:
[[email protected] ~]# echo 'export EDITOR=vim' >> ~/.bash_profile

Now test it. View any file using less or more.
Quote:
[[email protected] ~]# less ~/gagan.txt

Or
Quote:
[[email protected] ~]# more ~/gagan.txt

Now press v key to start the editor. This will start up an editor at current line and file.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group