Quick Vim Setup on AlmaLinux / Rocky Linux / RHEL 9

Bash scripting, Python automation, cron jobs, task scheduling, configuration management, and infrastructure automation.
Post Reply
Murali Krishna
Posts: 35
Joined: Wed Jun 10, 2026 8:34 am

Quick Vim Setup on AlmaLinux / Rocky Linux / RHEL 9

Post by Murali Krishna »

Quick Vim Setup on AlmaLinux / Rocky Linux / RHEL 9

If you've just installed a fresh server and want a better editing experience with Vim, this one-liner will:
  • Install Vim Enhanced
  • Make vi use Vim automatically
  • Enable syntax highlighting
  • Show line numbers
  • Improve search functionality
  • Enable auto-indent
  • Create a backup directory

Code: Select all

dnf -y install vim-enhanced && 
echo "alias vi='vim'" >> ~/.bashrc && 
source ~/.bashrc && 
mkdir -p ~/backup && 
cat > ~/.vimrc <<'EOF'
set nocompatible
set encoding=utf-8
set fileencodings=utf-8
set fileformats=unix,dos
set backup
set backupdir=~/backup
set history=50
set ignorecase
set smartcase
set hlsearch
set incsearch
set number
set showmatch
set autoindent
syntax on
highlight Comment ctermfg=LightCyan
set wrap
EOF
After running it, open any shell script with:

Code: Select all

vi script.sh
You'll get syntax highlighting, line numbers, search highlighting, and a much more comfortable editing experience compared to the default vi.
Post Reply