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.
|
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 |
Quote:
Code:
semoi@server:~$ v /usr/bin/vim |
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 |
Quote:
|
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. |
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! |
Quote:
Code:
export VISUAL=vim Quote:
|
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. |
Quote:
|
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?
|
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 Markus |
Thank you.
|
Quote:
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. |
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.
|
All times are GMT -5. The time now is 09:56 AM. |