LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 01-05-2004, 12:26 AM   #1
ICO
Member
 
Registered: Aug 2003
Location: ~/.
Distribution: CentOS
Posts: 290

Rep: Reputation: 30
How to make vim has syntax highlighting


When I use vim to write Java codes, it doesn't have syntax highlight. How to configure so that when I write C, C++, Java, XML, PHP etc(most of popular source codes) has syntax highlight?

Thanks a lot.
 
Old 01-05-2004, 12:55 AM   #2
slakmagik
Senior Member
 
Registered: Feb 2003
Distribution: Slackware
Posts: 4,113

Rep: Reputation: Disabled
At least ':syntax enable' and maybe specifically ':set syntax=java', I suppose.
 
Old 01-05-2004, 02:33 AM   #3
ICO
Member
 
Registered: Aug 2003
Location: ~/.
Distribution: CentOS
Posts: 290

Original Poster
Rep: Reputation: 30
Quote:
Originally posted by digiot
At least ':syntax enable' and maybe specifically ':set syntax=java', I suppose.
I tried "syntax enable" and it works, a little syntax, at least better than none.

"set syntax=java" not working.

And I didn't type ":" at the beginning, does it matter?
 
Old 01-05-2004, 02:39 AM   #4
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371
You don't mention if highlighting is working for something other then java code.

This should be present in /etc/vimrc (or ~/.vimrc)

" Vim syntax support file
so /usr/share/vim/vim61/syntax/syntax.vim

" Is gui running
if &t_Co > 2 || has("gui_running")
syntax on
set hlsearch
endif


The line pointing to syntax.vim: Make sure you use the correct path!!

Java has syntax support (take a look in the syntax dir).

Hope this helps.
 
Old 01-05-2004, 10:35 AM   #5
darthtux
Senior Member
 
Registered: Dec 2001
Location: 35.7480 N, 95.3690 W
Distribution: Debian, Gentoo, Red Hat, Solaris
Posts: 2,070

Rep: Reputation: 45
syntax on enables syntax highlighting for all languages vim supports.

The syntax color files are in
/usr/share/vim/vim61/syntax
In the above path vim 61 may be different on your system

You can copy one you want to change to
~/.vim/syntax/[file].vim
you will probably have to create the ~/.vim/syntax directory
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
RdHat Vim Syntax Highlighting R4z0r Linux - Software 8 09-06-2011 01:22 PM
vim syntax highlighting MiniMe001 Linux - General 2 06-19-2005 11:08 AM
Adding Syntax Highlighting to VIM TastyWheat Linux - Software 2 02-27-2004 03:37 AM
Java syntax highlighting in vim Phantomas Linux - Software 0 08-16-2003 04:34 AM
Vim syntax highlighting NSKL Linux - Software 2 11-09-2002 02:39 AM


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

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration