Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place. |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
09-10-2010, 06:31 PM
|
#1
|
Member
Registered: May 2009
Location: India
Distribution: On my PC I use RHEL, at office AIX, Solaris, HP-UX, RHEL.
Posts: 254
Rep:
|
Configuration File for Vi or Vim Editor for Syntax Highlighting
Hi,
On this Red Hat Box that I am using there is no .vimrc file for the user root. So, I created one and entered only one line to highlight syntax with colors when I am writing scripts in PHP and Bash. But it is not working.
Code:
[root@localhost ~]# cat ~/.vimrc
syntax on
[root@localhost ~]#
Any suggestions?
Note:
Code:
# vi --help
VIM - Vi IMproved 7.0 (2006 May 7, compiled May 4 2007 05:53:27)
|
|
|
09-10-2010, 08:51 PM
|
#2
|
Member
Registered: Aug 2007
Location: Vietnam
Distribution: RedHat based, Debian based, Slackware, Gentoo
Posts: 724
Rep: 
|
Does /etc/profile.d/vim.sh exist?
Code:
# cat /etc/profile.d/vim.sh
if [ -n "$BASH_VERSION" -o -n "$KSH_VERSION" -o -n "$ZSH_VERSION" ]; then
[ -x /usr/bin/id ] || return
tmpid=$(/usr/bin/id -u)
[ "$tmpid" = "" ] && tmpid=0
[ $tmpid -le 100 ] && return
# for bash and zsh, only if no alias is already set
alias vi >/dev/null 2>&1 || alias vi=vim
fi
If so, add an alias to /root/.bashrc:
and try again.
|
|
1 members found this post helpful.
|
09-11-2010, 01:05 PM
|
#3
|
Member
Registered: May 2009
Location: India
Distribution: On my PC I use RHEL, at office AIX, Solaris, HP-UX, RHEL.
Posts: 254
Original Poster
Rep:
|
Quote:
Originally Posted by quanta
Does /etc/profile.d/vim.sh exist?
Code:
# cat /etc/profile.d/vim.sh
if [ -n "$BASH_VERSION" -o -n "$KSH_VERSION" -o -n "$ZSH_VERSION" ]; then
[ -x /usr/bin/id ] || return
tmpid=$(/usr/bin/id -u)
[ "$tmpid" = "" ] && tmpid=0
[ $tmpid -le 100 ] && return
# for bash and zsh, only if no alias is already set
alias vi >/dev/null 2>&1 || alias vi=vim
fi
If so, add an alias to /root/.bashrc:
and try again.
|
Hi,
I found the file:
Code:
# cat /etc/profile.d/vim.sh
if [ -n "$BASH_VERSION" -o -n "$KSH_VERSION" -o -n "$ZSH_VERSION" ]; then
[ -x /usr/bin/id ] || return
[ `/usr/bin/id -u` -le 100 ] && return
# for bash and zsh, only if no alias is already set
alias vi >/dev/null 2>&1 || alias vi=vim
fi
(However, I don't understand what is going on in the above codes.)
So, I added the alias:
Code:
# cat ~/.bashrc
# .bashrc
# User specific aliases and functions
alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
alias vi='vim'
alias web='cd /var/www/html/'
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
and then issued this command:
and... voila!
Thanks for the help! 
|
|
|
09-11-2010, 01:09 PM
|
#4
|
Member
Registered: May 2009
Location: India
Distribution: On my PC I use RHEL, at office AIX, Solaris, HP-UX, RHEL.
Posts: 254
Original Poster
Rep:
|
Quote:
Please help me to correct my grammar mistakes.
|
Please help me correct my grammar mistakes.
Tam Biet! 
|
|
|
09-12-2010, 02:53 AM
|
#5
|
Member
Registered: Aug 2007
Location: Vietnam
Distribution: RedHat based, Debian based, Slackware, Gentoo
Posts: 724
Rep: 
|
Quote:
Originally Posted by Hi_This_is_Dev
Hi,
I found the file:
Code:
# cat /etc/profile.d/vim.sh
if [ -n "$BASH_VERSION" -o -n "$KSH_VERSION" -o -n "$ZSH_VERSION" ]; then
[ -x /usr/bin/id ] || return
[ `/usr/bin/id -u` -le 100 ] && return
# for bash and zsh, only if no alias is already set
alias vi >/dev/null 2>&1 || alias vi=vim
fi
(However, I don't understand what is going on in the above codes.)
|
In general, vi and vim are different. The above script only create alias for user whose id greater than 100 (Root's UID = 0)
Quote:
Originally Posted by Hi_This_is_Dev
Please help me correct my grammar mistakes.
Tam Biet! 
|
I have used this signature for three years, but you are the first to find out the mistake.
Last edited by quanta; 09-12-2010 at 10:40 AM.
|
|
|
09-12-2010, 10:33 AM
|
#6
|
Member
Registered: May 2009
Location: India
Distribution: On my PC I use RHEL, at office AIX, Solaris, HP-UX, RHEL.
Posts: 254
Original Poster
Rep:
|
Quote:
Originally Posted by quanta
In general, vi and vim are different. The above script only create alias for user who id greater than 100 (Root's UID = 0)
|
Thanks for the explanation. I got it now. Thanks again! 
|
|
|
All times are GMT -5. The time now is 02:23 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|