• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • VCS
  • Interview Questions
  • Database
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

How to enable text colour in vi similar to vim in CentOS/RHEL

by admin

If you use vim text editor, you would have seen the colorful text mark-up. It helps a lot in case you are writing scripts.

enable color text in vi similar to vim

By default vi editor does not have this feature enabled. Follow the steps below to enable the text colour feature in vi.

1. install vim-enhanced if not already installed.

# yum install vim-enhanced

2. Hash out the line containing “[ -n “$ID” -a “$ID” -le 200 ] && return“.

# vi /etc/profile.d/vim.sh

if [ -n "$BASH_VERSION" -o -n "$KSH_VERSION" -o -n "$ZSH_VERSION" ]; then
  [ -x /usr/bin/id ] || return
  ID=`/usr/bin/id -u`
  #[ -n "$ID" -a "$ID" -le 200 ] && return  ### hash out this line
  # for bash and zsh, only if no alias is already set
  alias vi >/dev/null 2>&1 || alias vi=vim
fi

3. Logout and login again to see the text color using vi.

text color with vi editor

Filed Under: Linux

Some more articles you might also be interested in …

  1. “az account” Command Examples
  2. How to use shell aliases in Linux
  3. fossil: Distributed version control system
  4. hsw-cli Command Examples
  5. cal: command not found
  6. git commit: Commit files to the repository
  7. How to Check CentOS Version
  8. tic Command Examples in Linux
  9. getopt Command Examples in Linux
  10. ss: command not found

You May Also Like

Primary Sidebar

Recent Posts

  • Vanilla OS 2 Released: A New Era for Linux Enthusiasts
  • mk Command Examples
  • mixxx Command Examples
  • mix Command Examples

© 2025 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright