LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 06-01-2013, 12:00 AM   #1
stf92
Senior Member
 
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 4,442

Rep: Reputation: 76
less and vi (for Slack users).


Hi: To change from an O.S to a new version of it can be upsetting. Example: When in slackware 12.0, when seeing text files with less, I sometimes made a little correction. I pressed 'v' and in this way entered vi. The tiny correction done, I returned to less. Now I have 14.0. If I press the 'v' key, again vi is invoked. But now vi comes with different default settings and, as a result, it's impossible for me to make the most elementary change to the edited file. I have two options: either make vi behave as before, by changieng its settings or make vim, whose default settings have not been changed, the less editor. Unfortunately it's not an easy thing to do either of these. I thought instructing less to use vim instead of vi would be an easy thing. After studying its man page for some hours, I had to give up. This of course is not slackware but plain linux. If you do not know how to do it, do not blame but your own ignorance, I mean.
 
Old 06-01-2013, 12:09 AM   #2
Diantre
Member
 
Registered: Jun 2011
Distribution: Slackware
Posts: 515

Rep: Reputation: 234Reputation: 234Reputation: 234
Set $VISUAL or $EDITOR in your environment to whatever editor you prefer, less will use $VISUAL first, if not set, it uses $EDITOR. It's actually very simple...

From the less manpage:
Code:
       v      Invokes an editor to edit the current file  being  viewed.   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.
              See also the discussion of LESSEDIT under the section on PROMPTS below.

Last edited by Diantre; 06-01-2013 at 12:12 AM.
 
2 members found this post helpful.
Old 06-01-2013, 12:18 AM   #3
stf92
Senior Member
 
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 4,442

Original Poster
Rep: Reputation: 76
Quote:
Originally Posted by Diantre View Post
Set $VISUAL or $EDITOR in your environment to whatever editor you prefer, less will use $VISUAL first, if not set, it uses $EDITOR. It's actually very simple...
I did it:
Code:
semoi@server:~$ v /usr/bin/vim  
-rwxr-xr-x 1 root root 2097864 2012-08-29 13:33 /usr/bin/vim*
semoi@server:~$ VISUAL=/usr/bin/vim
semoi@server:~$ echo $VISUAL
/usr/bin/vim
semoi@server:~$
But less still invokes vi!
 
Old 06-01-2013, 12:24 AM   #4
astrogeek
Moderator
 
Registered: Oct 2008
Distribution: Slackware [64]-X.{0|1|2|37|-current} ::12<=X<=15, FreeBSD_12{.0|.1}
Posts: 6,263
Blog Entries: 24

Rep: Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194
On a default Slackware vi is actually a symlink to elvis.

To make vi use vim for all uses, probably what you want, do this as root:

Code:
cd /usr/bin
rm vi
ln -s vim vi
then vi will invoke vim for all purposes.
 
Old 06-01-2013, 12:34 AM   #5
Diantre
Member
 
Registered: Jun 2011
Distribution: Slackware
Posts: 515

Rep: Reputation: 234Reputation: 234Reputation: 234
Quote:
Originally Posted by stf92 View Post
But less still invokes vi!
Well, I don't know then. In my system that only happens if VISUAL or EDITOR aren't defined. Maybe you could try exporting the variables or changing the vi symlink as astrogeek suggests.
 
Old 06-01-2013, 12:39 AM   #6
stf92
Senior Member
 
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 4,442

Original Poster
Rep: Reputation: 76
OK. But I am studying vi/elvis looking forward to use it as an editor. I would rather prefer operating at the less level. I wrote the assignment

VISUAL="/usr/bin/vim"

in /etc/profile. And I booted the machine. But still less invokes vi and not vim. There must be something odd in the settings of my O.S. (slackware 14.0). Maybe I'd rather post a thread in the linuxquestions>slackware forum.
 
Old 06-01-2013, 12:47 AM   #7
stf92
Senior Member
 
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 4,442

Original Poster
Rep: Reputation: 76
In /etc/profile, I added 'export' before the assigment. Now it is

export VISUAL=/usr/bin/vim

And now I get vim, in less. The 'export' token made all the difference!
 
Old 06-01-2013, 12:53 AM   #8
Diantre
Member
 
Registered: Jun 2011
Distribution: Slackware
Posts: 515

Rep: Reputation: 234Reputation: 234Reputation: 234
Quote:
Originally Posted by stf92 View Post
I wrote the assignment

VISUAL="/usr/bin/vim"

in /etc/profile.
I use ~/.bashrc for that:

Code:
export VISUAL=vim
export EDITOR=vim
Quote:
Originally Posted by stf92 View Post
Maybe I'd rather post a thread in the linuxquestions>slackware forum.
You just did.
 
Old 06-01-2013, 12:58 AM   #9
stf92
Senior Member
 
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 4,442

Original Poster
Rep: Reputation: 76
If I put it in /home/my_directory/.bashrc then I will have to put in /root/.bashrc too and in my girl friend's directory as well. Using /etc/profile, I'm making the setting system wide.

But why is it necessary to export the variable. If I don't export it, after boot I can see it anyway (echo $VISUAL), THOUGH it's obvious that less does not.

Last edited by stf92; 06-01-2013 at 01:00 AM.
 
Old 06-01-2013, 02:59 AM   #10
Diantre
Member
 
Registered: Jun 2011
Distribution: Slackware
Posts: 515

Rep: Reputation: 234Reputation: 234Reputation: 234
Quote:
Originally Posted by stf92 View Post
But why is it necessary to export the variable. If I don't export it, after boot I can see it anyway (echo $VISUAL), THOUGH it's obvious that less does not.
It's necessary to export the variables so subprocesses can use them. When you declare a variable as VAR=value, that's a shell variable. When the export keyword is used, the variable becomes an environment variable, and is available to subprocesses, 'less' in this case. More info here.
 
Old 06-01-2013, 03:16 AM   #11
stf92
Senior Member
 
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 4,442

Original Poster
Rep: Reputation: 76
Are not the variables output by the set command without arguments all of them environment variables? You mean that if, in /etc/profile, I don't prefix the variable name with 'export' then 'set' wont display it?
 
Old 06-01-2013, 03:49 AM   #12
markush
Senior Member
 
Registered: Apr 2007
Location: Germany
Distribution: Slackware
Posts: 3,979

Rep: Reputation: Disabled
Hi,

if you want to use VISUAL or EDITOR as environment-variables, you should in your /etc/profile (or in local .profile or .bashrc) do the following
Code:
VISUAL=/usr/bin/vim
EDITOR=/usr/bin/vim
export VISUAL
export EDITOR
this will work in most cases.

Markus
 
Old 06-01-2013, 03:53 AM   #13
stf92
Senior Member
 
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 4,442

Original Poster
Rep: Reputation: 76
Thank you.
 
Old 06-01-2013, 04:37 AM   #14
Diantre
Member
 
Registered: Jun 2011
Distribution: Slackware
Posts: 515

Rep: Reputation: 234Reputation: 234Reputation: 234
Quote:
Originally Posted by stf92 View Post
Are not the variables output by the set command without arguments all of them environment variables? You mean that if, in /etc/profile, I don't prefix the variable name with 'export' then 'set' wont display it?
No and no.

I didn't mention "set" nor /etc/profile. I don't "mean" anything. I only answered your previous question about why 'less' wasn't seeing a shell variable. RTFM.
 
Old 06-01-2013, 06:04 AM   #15
stf92
Senior Member
 
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 4,442

Original Poster
Rep: Reputation: 76
I've read the F manual, as you say, 13467 times and still can't make any sense of it. On the other hand, I don't have to read any manual if I want to ask a question. Are you some busy developer that answers questions as an act of charity? Besides, I did not ask you to answer any question. If you want to respond, that's your business.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Hello Slack users et. al. User0x45 LinuxQuestions.org Member Intro 4 08-17-2015 12:23 AM
6 Slack-users use what ? daviddutch1964 Slackware 15 07-13-2007 10:48 PM
Any Slack users? hepburnenthorpe Slackware 10 04-12-2007 09:30 AM
adding users to slack e1000 Slackware 1 10-22-2003 07:56 PM
Sound in Slack for users Tinkster Slackware 7 05-17-2002 10:37 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 11:12 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration