LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 02-11-2006, 10:54 PM   #1
kdogksu
Member
 
Registered: Dec 2004
Location: Kansas, United States
Distribution: Ubuntu
Posts: 52

Rep: Reputation: 16
GVIM syntax highlighting gone!


I love gvim and use it all the time for coding. However, it recently quit doing syntax highlighting, and I can't figure out why. I open a file with extention .c or .cpp, and all the text is plain black, whereas it used to be highlighted when I would do this. It is possible that this coincided with a debian dist-upgrade, but I can't be sure, as I didn't use gvim for a while after doing it. The following is my .gvimrc file, which is the same as my /etc/vim/gvimrc:

Code:
" Configuration file for gvim
" Written for Debian GNU/Linux by W.Akkerman <wakkerma@debian.org>

" Make external commands work through a pipe instead of a pseudo-tty
"set noguipty
" Switch syntax highlighting on, when the terminal has colors

" Make shift-insert work like in Xterm
map <S-Insert> <MiddleMouse>
map! <S-Insert> <MiddleMouse>

" Also switch on highlighting the last used search pattern.
if has("syntax") && (&t_Co > 2 || has("gui_running"))
  syntax on
  set hlsearch
endif

" You can also specify a different font:
" set guifont=-misc-fixed-medium-r-normal--14-130-75-75-c-70-iso8859-1
It looks to me like syntax highlighting should be turned on. Am I missing something obvious? I'd be glad to post any other files to help.

Thanks!
 
Old 02-12-2006, 12:10 AM   #2
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
My sample vimrc is a little different. It looks like the has("syntax") test is failing.
Code:
" Switch syntax highlighting on, when the terminal has colors
" Also switch on highlighting the last used search pattern.
if &t_Co > 2 || has("gui_running")
  syntax on
  set hlsearch
endif
The has("syntax") test, should be a test on whether this feature is compiled in or not. That indicates to me that you may have replaced the gvim binary with one that doesn't have syntax highlighting support compiled in. Perhaps a security upgrade.

You could try entering ':syn on' and see what happens.

Also check if your filetype.vim file got deleted.

Last edited by jschiwal; 02-12-2006 at 12:15 AM.
 
Old 02-12-2006, 04:43 PM   #3
kdogksu
Member
 
Registered: Dec 2004
Location: Kansas, United States
Distribution: Ubuntu
Posts: 52

Original Poster
Rep: Reputation: 16
Thanks for the advice!

/usr/share/vim/vim64/filetype.vim exists, so I don't think that's the problem.

':version' gives the following, which indicates that syntax highlighting is compiled in.

:version
VIM - Vi IMproved 6.4 (2005 Oct 15, compiled Jan 15 2006 18:53:29)
Included patches: 1-6
Compiled by nobse@debian.org
Big version with GTK2 GUI. Features included (+) or not (-):
+arabic +autocmd +balloon_eval +browse ++builtin_terms +byte_offset +cindent
+clientserver +clipboard +cmdline_compl +cmdline_hist +cmdline_info +comments
+cryptv +cscope +dialog_con_gui +diff +digraphs +dnd -ebcdic +emacs_tags +eval
+ex_extra +extra_search +farsi +file_in_path +find_in_path +folding -footer
+fork() +gettext -hangul_input +iconv +insert_expand +jumplist +keymap +langmap
+libcall +linebreak +lispindent +listcmds +localmap +menu +mksession
+modify_fname +mouse +mouseshape +mouse_dec +mouse_gpm -mouse_jsbterm
+mouse_netterm +mouse_xterm +multi_byte +multi_lang +netbeans_intg -osfiletype
+path_extra -perl +postscript +printer -python +quickfix +rightleft -ruby
+scrollbind +signs +smartindent -sniff +statusline -sun_workshop +syntax
+tag_binary +tag_old_static -tag_any_white -tcl +terminfo +termresponse
+textobjects +title +toolbar +user_commands +vertsplit +virtualedit +visual
+visualextra +viminfo +vreplace +wildignore +wildmenu +windows +writebackup
+X11 -xfontset +xim +xsmp_interact +xterm_clipboard -xterm_save

When I type ':syn on', I get the following error in red at the bottom of the screen:

Error detected while processing /usr/share/vim/vim64/syntax/syntax.vim:
line 42:
E216: No such group or event: filetypedetect BufRead
Hit ENTER or type command to continue

I don't know what to make of that. Any ideas? Here's the whole file:

Code:
" Vim syntax support file
" Maintainer:	Bram Moolenaar <Bram@vim.org>
" Last Change:	2001 Sep 04

" This file is used for ":syntax on".
" It installs the autocommands and starts highlighting for all buffers.

if !has("syntax")
  finish
endif

" If Syntax highlighting appears to be on already, turn it off first, so that
" any leftovers are cleared.
if exists("syntax_on") || exists("syntax_manual")
  so <sfile>:p:h/nosyntax.vim
endif

" Load the Syntax autocommands and set the default methods for highlighting.
runtime syntax/synload.vim

" Load the FileType autocommands if not done yet.
if exists("did_load_filetypes")
  let s:did_ft = 1
else
  filetype on
  let s:did_ft = 0
endif

" Set up the connection between FileType and Syntax autocommands.
" This makes the syntax automatically set when the file type is detected.
augroup syntaxset
  au! FileType *	exe "set syntax=" . expand("<amatch>")
augroup END


" Execute the syntax autocommands for the each buffer.
" If the filetype wasn't detected yet, do that now.
" Always do the syntaxset autocommands, for buffers where the 'filetype'
" already was set manually (e.g., help buffers).
doautoall syntaxset FileType
if !s:did_ft
  doautoall filetypedetect BufRead
endif
 
Old 02-13-2006, 03:44 AM   #4
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
Code:
    36  " Execute the syntax autocommands for the each buffer.
    37  " If the filetype wasn't detected yet, do that now.
    38  " Always do the syntaxset autocommands, for buffers where the 'filetype'
    39  " already was set manually (e.g., help buffers).
    40  doautoall syntaxset FileType
    41  if !s:did_ft
    42    doautoall filetypedetect BufRead
    43  endif
My syntax.vim ends the same way yours does.
Code:
  " Execute the syntax autocommands for the each buffer.
    37  " If the filetype wasn't detected yet, do that now.
    38  " Always do the syntaxset autocommands, for buffers where the 'filetype'
    39  " already was set manually (e.g., help buffers).
    40  doautoall syntaxset FileType
    41  if !s:did_ft
    42    doautoall filetypedetect BufRead
    43  endif
I wonder if line 42 is actually after the error.

Oh, also check your .viminfo file for anything weird, and check if you have a ~/.vimrc file. If so, do you have a :syntax on command in this file?

Were any of these configuration files edited in windows? I've seen it occasionally where a configuration file look ok but it didn't work until an invisible white space character was removed.

Also double check the c.vim and cpp.vim files. I use vim version 63 so differences are possible. Also, I have vim and kvim installed.

How do you run validity tests in debian? On SuSE, I can run:
rpm -V vim
rpm -V gvim

I'm sure that you have the same sort of command to check the validity of files on your system. Especially the /usr/share/vim/... files. If line 42 is erroring out, It seems that it is one of the configuration scripts that are called by that line.

Last edited by jschiwal; 02-13-2006 at 03:52 AM.
 
Old 02-24-2006, 09:47 PM   #5
kdogksu
Member
 
Registered: Dec 2004
Location: Kansas, United States
Distribution: Ubuntu
Posts: 52

Original Poster
Rep: Reputation: 16
Sorry for the delay. With a little more poking around on the internet, I discovered that syntax highlighting is broken for several filetypes in VIM6.4, which I recently upgraded to (through a normal dist-upgrade). To fix it, I just pinned the VIM versions in my /etc/apt/preferences file:

Code:
Package: vim-gtk
Pin: version 1:6.3-071+1sarge1
Pin-Priority: 1001

Package: vim
Pin: version 1:6.3-071+1sarge1
Pin-Priority: 1001

Package: vim-common
Pin: version 1:6.3-071+1sarge1
Pin-Priority: 1001
This forces apt to downgrade to 6.3 (a priority above 1000 allows a downgrade). I realize this is undesirable, but fixes my problem for the moment. Perhaps it won't be long before 6.4 is fixed. Thanks for your help!
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Syntax highlighting in Gedit jriis Linux - Software 1 10-24-2005 06:16 AM
syntax highlighting rohr Programming 3 07-06-2005 06:07 AM
vim syntax highlighting MiniMe001 Linux - General 2 06-19-2005 11:08 AM
xemacs syntax highlighting jclark00001 Linux - Software 2 04-13-2003 04:40 PM
Vim syntax highlighting NSKL Linux - Software 2 11-09-2002 02:39 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 07:41 PM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration