LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
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


Reply
  Search this Thread
Old 09-10-2010, 06:31 PM   #1
Hi_This_is_Dev
Member
 
Registered: May 2009
Location: India
Distribution: On my PC I use RHEL, at office AIX, Solaris, HP-UX, RHEL.
Posts: 254

Rep: Reputation: 18
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)
 
Old 09-10-2010, 08:51 PM   #2
quanta
Member
 
Registered: Aug 2007
Location: Vietnam
Distribution: RedHat based, Debian based, Slackware, Gentoo
Posts: 724

Rep: Reputation: 101Reputation: 101
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:
Code:
alias vi='vim'
and try again.
 
1 members found this post helpful.
Old 09-11-2010, 01:05 PM   #3
Hi_This_is_Dev
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: Reputation: 18
Quote:
Originally Posted by quanta View Post
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:
Code:
alias vi='vim'
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:

Code:
# source .bashrc
and... voila!

Thanks for the help!
 
Old 09-11-2010, 01:09 PM   #4
Hi_This_is_Dev
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: Reputation: 18
Quote:
Please help me to correct my grammar mistakes.

Please help me correct my grammar mistakes.

Tam Biet!
 
Old 09-12-2010, 02:53 AM   #5
quanta
Member
 
Registered: Aug 2007
Location: Vietnam
Distribution: RedHat based, Debian based, Slackware, Gentoo
Posts: 724

Rep: Reputation: 101Reputation: 101
Quote:
Originally Posted by Hi_This_is_Dev View Post
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 View Post
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.
 
Old 09-12-2010, 10:33 AM   #6
Hi_This_is_Dev
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: Reputation: 18
Quote:
Originally Posted by quanta View Post
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!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Vim syntax highlighting Gortex Programming 1 08-18-2008 05:43 PM
VIM Syntax Highlighting JMJ_coder Programming 3 03-05-2008 04:37 PM
[SOLVED] vim without syntax highlighting lord_didger Debian 5 11-18-2006 01:29 PM
vim syntax highlighting MiniMe001 Linux - General 2 06-19-2005 11:08 AM
syntax highlighting for ls command and vim editor cseanburns Other *NIX 0 01-02-2005 03:11 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 02:23 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