Results 1 to 4 of 4
When I edit a shell script as my regular user account, keywords within the script are colorful. Variables are dark blue, text inside double-quotes is pink, shell commands are yellow, ...
- 08-15-2011 #1Just Joined!
- Join Date
- Jul 2009
- Posts
- 3
Colorful vi
When I edit a shell script as my regular user account, keywords within the script are colorful. Variables are dark blue, text inside double-quotes is pink, shell commands are yellow, comments after a # are cyan.
When I edit the same files using vi as root, there are no colors. My guess is that this is configured in .profile or .bash_profile or something like that in each user's home directory, but I cannot find the specific file. So, do anyone know how to make vi colorful for root as well?
Thanks in advance...
- 08-15-2011 #2forum.guy
- Join Date
- May 2004
- Location
- arch linux
- Posts
- 18,096
Hello
If you haven't tried it, I believe vim can display in color as root user but not sure about vi.
Maybe someone else will have more info for you.oz
→ new members/users: read this first | new member faq
→ no private messages requesting computer support - post them on the forums!
→ please use the "report post" button to alert our forum admins to problematic posts rather than responding to them yourself.
- 08-16-2011 #3Just Joined!
- Join Date
- Aug 2011
- Posts
- 5
you would be better suited using vim.
- 08-16-2011 #4Linux Guru
- Join Date
- May 2011
- Posts
- 1,842
First make sure vim is installed, as was suggested:
If installed, it will likely be in /usr/bin/vim.Code:which vim
Now as root, do this, in a terminal:
if it reports an alias pointing to 'vim', then no changes needed there. if it reports 'vi', then put something like this in root's ~/.bashrc:Code:which vi
now source the file, so that vi is aliased to vim.Code:alias vi='/usr/bin/vim'
next, open a file as root with vi, say /etc/bashrc (so we know there is syntax highlighting to be able to see). in it turn on syntax highlighting with this:
If the colors do not appear, then something is wrong - post back. But if the colors do appear, then quit out of vi and add something like this to your vim profile, ~/.vimrc:Code::syntax on
That should do it.Code:syntax on
NOTE: some versions of Fedora/Red Hat would put a line in /etc/profile.d/vim.sh to not allow root users to alias vi to vim for some crazy ass reason.


Reply With Quote