LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   color highlight in VIM - howyoudothat? (https://www.linuxquestions.org/questions/linux-software-2/color-highlight-in-vim-howyoudothat-565358/)

chewmanfoo 06-29-2007 08:19 AM

color highlight in VIM - howyoudothat?
 
Guys,

I recently installed vim on a server at work. When I edit a source code file with vim, I see various fonts (plain and bold) in various shades of grey. However, on my A2 Web Hosting shell account, when I vim a file, I see pretty colors.

What do I have to do to see pretty colors on a vim screen on my server at work? I have my bash shell showing pretty colors, so I know the problem is not with my terminal window (WRQ Reflections for Unix/Digital).

TIA,
chewy

hacker supreme 06-29-2007 09:47 AM

IIRC, you go into vim and type :syntax=on to enable syntax highlighting by file.

(I think... Mine just keeps telling me that "E319: Sorry, the command is not available in this version" so I can't check.)

Oh, and there should be a file in your $HOME called .vimrc (IIRC) that you can add this to, so that it's always on. /* Prays that he's got this right... */

sleepyEDB 06-29-2007 09:48 AM

When in vim, try this:

Type : to get a command line,

Type 'runtime syntax/colortest.vim' to make sure you do in fact have the ability to display color from the server. (I know you said it did, but just to be sure! :) )



If the above worked, try editing the .vimrc file in your home directory to include the following lines:
Code:

" Set syntax highlighting to always on
syntax enable

" Set the background to dark and the colorscheme to murphy
set background=dark
colorscheme murphy

" Set automatic filetype detection to on
filetype on

That should at least get you some color. You certainly don't have to keep the murphy colorscheme...I just included that bit so you'd have a color scheme to start with.

To see all available colorschemes, see this page:
http://www.cs.cmu.edu/~maverick/VimColorSchemeTest/index-pl.html

I will warn you that the page may take a long time to load on a slow connection since there are almost 300 pictures showing the various colorscheme/background combos!


sleepy

slackhack 06-29-2007 10:29 AM

i'm okay with my colorscheme, but i was just trying this out of curiosity, and i get this error message:

Code:

jeff@bart:~ $ vim .vimrc
Error detected while processing /home/jeff/.vimrc:
line    6:
E518: Unknown option: colorscheme
Press ENTER or type command to continue

it works when i issue the command from within vim, though. any idea what might be wrong?

sleepyEDB 06-29-2007 10:48 AM

slackhack -

Thanks for catching that. I mistakenly put the 'set' in front of 'colorscheme' in my code above. I have since removed the 'set'...the correct option in your .vimrc should be:

Code:

colorscheme murphy
Sorry for the mistake! :eek:



sleepy

chewmanfoo 06-29-2007 04:53 PM

doesn't work for me
 
After I corrected that "set colorscheme" defect, I start vi on an html file, and I see a lot of formatting, but no color. It's underlining angle brackets and changing the weight of the font for paragraph, title etc. elements in the html, but its not showing it in color.

What gives?
chewy

ak_random 06-29-2007 04:59 PM

Quote:

Originally Posted by chewmanfoo
What do I have to do to see pretty colors on a vim screen on my server at work? I have my bash shell showing pretty colors, so I know the problem is not with my terminal window (WRQ Reflections for Unix/Digital).

Although your terminal window might be capable of displaying text in colors, it still has to tell vim that it can. For example, different term windows (xterm vs rxvt) may have slightly different color capabilities. Within vim, do ":h color-xterm" and see if one of the settings in there will work.

chewmanfoo 07-02-2007 08:23 AM

That worked!
 
I had my TERM set to linux or vt220, both of which did not work for color syntax in vim. But xterm did. Thanks for the help!


All times are GMT -5. The time now is 11:10 PM.