LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Configuration File for Vi or Vim Editor for Syntax Highlighting (https://www.linuxquestions.org/questions/linux-general-1/configuration-file-for-vi-or-vim-editor-for-syntax-highlighting-831474/)

Hi_This_is_Dev 09-10-2010 06:31 PM

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)


quanta 09-10-2010 08:51 PM

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_This_is_Dev 09-11-2010 01:05 PM

Quote:

Originally Posted by quanta (Post 4094030)
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! :)

Hi_This_is_Dev 09-11-2010 01:09 PM

Quote:

Please help me to correct my grammar mistakes.

Please help me correct my grammar mistakes. :)

Tam Biet! :hattip:

quanta 09-12-2010 02:53 AM

Quote:

Originally Posted by Hi_This_is_Dev (Post 4094539)
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 (Post 4094544)
Please help me correct my grammar mistakes. :)

Tam Biet! :hattip:

I have used this signature for three years, but you are the first to find out the mistake.

Hi_This_is_Dev 09-12-2010 10:33 AM

Quote:

Originally Posted by quanta (Post 4094968)
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 01:56 PM.