[vim] Syntax Highlighting Takes a Holiday



Hi y'all,

On the job I use RCS for version control under Windows. Quite often I begin to modify a file only to be warned it is read only. So, to avoid having to go to a DOS window and check out the file, I wrote a vim function to do it and set it up to be triggered by the FileChangedRO event. I've included the code below.

The problem I'm writing about is after the "edit" command, all the foreground colors change to either white or black, depending on the background, dark or light. I have to manually enable syntax highlighting via "syntax enable" or "syntax on" to restore the colors in the colorscheme. This is why you see the "syntax enable" command in my function after edit.

So, does anyone know why it is that syntax highlighting seemingly takes a holiday?

Feel free to make "constructive" comments on the code if you must!  ;)

Mike


Code from _gvimrc below:

autocmd FileChangedRO *  call FileChangedCmd()
function FileChangedCmd()
    let fname = expand("%:t")
    let hasrcs = filereadable("./RCS/" . fname)
    if hasrcs == 0
	echo "You are modifying a read-only file."
    else
	let choice = confirm("Check it out?","&Yes\n&No",1,"Q")
	if choice == 1
	    let cur_line = line(".")
	    let cur_col  =  col(".")
	    call inputsave()
	    let rc = system("C:/rcs/bin/win32/co -l " . fname)
	    edit
	    syntax enable
	    call inputrestore()
	    call cursor(cur_line,cur_col)
	endif
    endif
endfunction
.



Relevant Pages

  • Configure a DUN phone number using vbscript
    ... in windows XP i noticed that i can't modify the phonebook file because it is encrypted. ... does anyone know of a way to edit a phone number in a phone book file in windows xp without opening up the dial Up connections gui ...
    (microsoft.public.windowsxp.network_web)
  • Re: Permission Changes
    ... Does windows consider that a form of ... >> Is there a special combination of permissions that will ... >> to edit and delete the file, ... >> affect the ability to delete and modify at all(strange, ...
    (microsoft.public.windows.file_system)
  • File Information
    ... When you hold the mouse over a file in the Windows Explore you get a box ... of the files types. ... Is it possible to change, modify, edit or add information to this little ...
    (microsoft.public.windowsxp.basics)
  • Re: Need help with netstat and connections running in background
    ... Right click on the cmd Title bar, point to Edit and click on Select All. ... Alt + Spacebar opens context menu ... You can type in a command prompt: ... How to start Windows in Safe Mode Windows XP ...
    (microsoft.public.windowsxp.general)
  • Re: IE 6 Will not open inside specific User Profile
    ... Click Advanced or Edit, ... You Cannot Open New Internet Explorer Window or Nothing Happens After You ... >I have a client that is running Windows XP Home SP1 on a Dell system. ... > unable to register it because whenever I tried to register it, ...
    (microsoft.public.windows.inetexplorer.ie6.browser)