When in vi use :split for split view of two files, use Ctrl+W to toggle
for rpm query of only names
rpm -qa --queryformat='%{NAME} \n' | sort -n
or using awk
rpm -qa | awk -F"-[0-9]" '{ print $1}'
for grep with highlight of matched word,
grep --color word file