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

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • 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. uuidgen: command not found
  2. bmon: command not found
  3. cpufreq-aperf: command not found
  4. CentOS / RHEL : How to Recover from deleted /etc/passwd file
  5. How to Restrict Active Directory Users and Groups to Login to CentOS/RHEL 7 Client
  6. Linux / UNIX : Examples of find command to find files with specific sets of permissions
  7. virsh Command Examples in Linux
  8. How to Automate Startup/Shutdown of Oracle Database and Listener on Linux
  9. How to use “yum downloadonly” to download a package without installing it
  10. How to recover from a corrupt RPM database (rebuilding an RPM database)

You May Also Like

Primary Sidebar

Recent Posts

  • qsub Command Examples in Linux
  • qsub: command not found
  • qrcp Command Examples in Linux
  • qmrestore Command Examples in Linux

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright