This problem has been troubling me until recently. When I use the vi editor as user “root”, the vi syntax is not working. However, the vi syntax works perfectly fine when you log on as other user.

The solution is simple, use vim instead of vi.

The cause of this lies in in /etc/profile.d/vim.* . vi only aliases to vim for user id greater than 100. User “root” is lower than 100 so it isn’t not aliased.

I believe the syntax files may not be available during boot level 1(single user mode), so vim is only used for other users.

—-

Note:
If you don’t even have syntax color for normal users, make sure you have vim-full installed
$ apt-get install vim-full

then in vi, turn it on by : syntax on
or edit /etc/vim/vimrc and turn it on by default

Advertisements