YGirouard | 1 Mar 2008 04:03

Unable to get syntax highlighting to work for root account


Problem description: Whenever I switch to the root account using "su - root",
the syntax highlighting in vi stops working. It works fine when I'm using my
own account since I added "syntax on" in the file ~/.vimrc, but I tried
adding the same file to the /root directory and it's not doing anything for
root. I also tried typing the "syntax on" in vi after launching it as root,
and nothing happens.

The command "echo $TERM" returns "xterm" as both root and my own account.

I also tried to force "syntax on" in /etc/vimrc (adding it at the end,
outside the IF block that usually sets it), and it does nothing. I compared
the environment variables for both users (my own and root) and I can't see
anything that would cause this...

I restarted my server and still doesn't work... I'm out of things to look at
and google isn't much of a friend this time... I managed to find ONE post
from someone with the same problem, but nobody was able to provide him with
a working solution...

Additional info:
------------------------------------------------------------------------
SSH Client: Putty (in Windows Xp Pro)
OS: Fedora Core 7
VIM Packages installed (obtained using command: yum list installed vim*):

 vim-common.i386, 2:7.1.211-1.fc7, installed
 vim-enhanced.i386, 2:7.1.211-1.fc7, installed
 vim-minimal.i386, 2:7.1.211-1.fc7, installed

(Continue reading)

Tony Mechelynck | 1 Mar 2008 04:40
Picon
Gravatar

Re: Unable to get syntax highlighting to work for root account


YGirouard wrote:
> 
> Problem description: Whenever I switch to the root account using "su - root",
> the syntax highlighting in vi stops working. It works fine when I'm using my
> own account since I added "syntax on" in the file ~/.vimrc, but I tried
> adding the same file to the /root directory and it's not doing anything for
> root. I also tried typing the "syntax on" in vi after launching it as root,
> and nothing happens.
[...]

Is it for every filetype (including c, html, etc.) or only for some of them 
(such as help, which is set by a modeline)?

Modelines are intentionally disabled for the root account starting at 
patchlevel 7.0.237 (see http://ftp.vim.org/pub/vim/patches/README and search 
for 7.0.237). This is how I enable them even for root:

if exists("+modelines")
	" the following is required because of SuSE's paranoid /etc/vimrc
	" and to force 'modeline' on even for root in Vim 7.0.237 and later
	set modeline modelines=5
	" the following disables a dangerous modeline in one helpfile
	if has ('autocmd')
		au BufReadPost ada.txt setl nomodeline ft=help
	endif
endif

Beware that obnoxious modelines have been spotted time and again. The most 
dangerous options are disabled in them, but maybe some dangerous ones have 
(Continue reading)

Tony Mechelynck | 1 Mar 2008 04:55
Picon
Gravatar

Re (OOPS): Unable to get syntax highlighting to work for root account


Tony Mechelynck wrote:
> YGirouard wrote:
>> Problem description: Whenever I switch to the root account using "su - root",
>> the syntax highlighting in vi stops working. It works fine when I'm using my
>> own account since I added "syntax on" in the file ~/.vimrc, but I tried
>> adding the same file to the /root directory and it's not doing anything for
>> root. I also tried typing the "syntax on" in vi after launching it as root,
>> and nothing happens.
> [...]
> 
> Is it for every filetype (including c, html, etc.) or only for some of them 
> (such as help, which is set by a modeline)?
> 
> Modelines are intentionally disabled for the root account starting at 
> patchlevel 7.0.237 (see http://ftp.vim.org/pub/vim/patches/README and search 

Oops! http://ftp.vim.org/pub/vim/patches/7.0/README

> for 7.0.237). This is how I enable them even for root:
> 
> if exists("+modelines")
> 	" the following is required because of SuSE's paranoid /etc/vimrc
> 	" and to force 'modeline' on even for root in Vim 7.0.237 and later
> 	set modeline modelines=5
> 	" the following disables a dangerous modeline in one helpfile
> 	if has ('autocmd')
> 		au BufReadPost ada.txt setl nomodeline ft=help
> 	endif
> endif
(Continue reading)

Thomas Köhler | 1 Mar 2008 06:12
Picon

Re: The Ultimate Vimmer

Gary Johnson wrote:
> On 2008-02-25, Thomas Khler <jean-luc <at> picard.franken.de> wrote:
> > ThoML wrote:
> > > > as I didn't find out how to use CTRL-] there...)
> > > 
> > > <c-+>
> > > 
> > > It sometimes helps to check out the US keyboard layout.
> > > 
> > > I'm not sure though if/how this gets through to your remote system.
> > 
> > That's exactly the problem. This usually doesn't work remotely :-(
> 
> ^] is the telnet escape character.  If you're using telnet, you can 
> change the escape character to something else or disable it 
> entirely.

I haven't used telnet in years.
Maybe it's putty's fault, but maybe it's also a problem when you
login to some windows terminal servers[1] and then try to use
some keys...

[1] Remote access to work is sometimes done that way...

> HTH,
> Gary

Ciao,
Thomas

(Continue reading)

YGirouard | 1 Mar 2008 08:29

Re: Re (OOPS): Unable to get syntax highlighting to work for root account


Thanks Tony,

Not sure it applies to my issue though, as it's doing it for every filetype
(conf files, php files, perl, etc). As for the additional details you asked,
it was partially in the "Additional Info" section of my post but here goes
anyway... let me know if that helps:

I'm using Linux RedHat Fedora Core 7 on a virtual dedicated server. I only
have shell access (no gui).

The version output of vi echoes this (I put the whole thing anyway in
case...):

VIM - Vi IMproved 7.1 (2007 May 12, compiled Jan  9 2008 08:28:40)
Included patches: 1-211
Modified by <bugzilla <at> redhat.com>
Compiled by <bugzilla <at> redhat.com>
Small version without 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 -cursorshape -dialog -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 -mouse_dec -mouse_gpm -mouse_jsbterm -mouse_netterm
-mouse_xterm +multi_byte -multi_lang -mzscheme -netbeans_intg -osfiletype
(Continue reading)

YGirouard | 1 Mar 2008 08:32

Re: Re (OOPS): Unable to get syntax highlighting to work for root account


I think I found the issue, but I don't know how to fix it...

Looks like the root account is not using the same package of VI the other
accounts are using... This is what I get when I type vi --version as my own
account: (notice the +syntax instead of -syntax, and the Huge version
instead of Small...). How can I fix this for root???

VIM - Vi IMproved 7.1 (2007 May 12, compiled Jan  9 2008 08:28:18)
Included patches: 1-211
Modified by <bugzilla <at> redhat.com>
Compiled by <bugzilla <at> redhat.com>
Huge version without 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 +cursorshape +dialog_con +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 -mzscheme
-netbeans_intg -osfiletype +path_extra +perl +postscript +printer +profile
+python +quickfix +reltime +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
(Continue reading)

YGirouard | 1 Mar 2008 08:45

Re: Re (OOPS): Unable to get syntax highlighting to work for root account


Ok, I fixed it... all I had to do was to add an alias for vi pointing to
/usr/bin/vim in my /root/.bashrc file. Root was using /bin/vi which is the
Small version, while other accounts were aliasing vi as vim, which is why it
was working... I was also able to get syntax to work as root by using just
"vim filename" instead of vi... Silly me... Thanks for pointing me in the
right direction Tony! :)

YGirouard wrote:
> 
> I think I found the issue, but I don't know how to fix it...
> 
> Looks like the root account is not using the same package of VI the other
> accounts are using... This is what I get when I type vi --version as my
> own account: (notice the +syntax instead of -syntax, and the Huge version
> instead of Small...). How can I fix this for root???
> 
> VIM - Vi IMproved 7.1 (2007 May 12, compiled Jan  9 2008 08:28:18)
> Included patches: 1-211
> Modified by <bugzilla <at> redhat.com>
> Compiled by <bugzilla <at> redhat.com>
> Huge version without 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 +cursorshape +dialog_con +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
(Continue reading)

haron | 1 Mar 2008 11:03
Picon

w32 gvim expand("[b...]") = "b" if current directory contains /b folder


Looks like expand() recognizes "[<letter>...]" construct as name
of directory <letter>, if directory <letter> is contained in
current directory. In ":help expand" isn't mentioned any special
meaning for "[]" characters.  They seems to have effect only if
there both - left and right "[" "]" square brackets are present.
Is this is a desired behavior ? If not, I will may be try to look
to expand() implementation ?

Example, demonstrating the "problem":

$ cd c:\tst
$ dir /s/b
c:\tst\b
c:\tst\c
$ gvim -u NONE -U NONE
:echo expand("[BufferExplorer]")
b
:echo expand("[CufferExplorer]")
c
:echo expand("BufferExplorer")
BufferExplorer
:echo expand("CufferExplorer")
CufferExplorer
:echo expand("[BufferExplorer")
[BufferExplorer
:cd ..
:echo expand("[BufferExplorer]")
[BufferExplorer]
:echo expand("[CufferExplorer]")
(Continue reading)

haron | 1 Mar 2008 11:06
Picon

Re: crash w32 gvim 7.1 (2007 May 12) with BufExplore


Thread is closed (subject isn't match any more).
I have started new thread:

http://groups.google.com/group/vim_use/browse_thread/thread/552ba1361e885013
"w32 gvim expand("[b...]") = "b" if current directory contains /b
folder"

to continue discussion with proper subject.
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Richard Hartmann | 1 Mar 2008 11:46
Picon
Gravatar

Re: Unable to get syntax highlighting to work for root account


On Sat, Mar 1, 2008 at 4:40 AM, Tony Mechelynck
<antoine.mechelynck <at> gmail.com> wrote:

>  Beware that obnoxious modelines have been spotted time and again. The most
>  dangerous options are disabled in them, but maybe some dangerous ones have
>  been mistakenly allowed: if you enable them for the superuser, you're on your
>  own. You may get no problems at all, but if bugs bite you, don't say you
>  weren't warned.

To guard against surprise modelines in files, use:

" This function will check if VIM finds modelines and, if yes, will let you
" choose if you want to execute them. Edit default to enable or disable,
" according to your needs. You can use y and n, as well.
function s:CheckForModelines()
    " 'default' may only be set to e[nable], d[isable] and, for
convenience, y[es] or n[o]
    let default = 'e'

    if default != 'e' && default != 'd' && default != 'y' && default != 'n'
        echoerr "Error in function CheckForModelines: Please set
'default' to 'e', 'd', 'y' or 'n'"
    endif
    if !exists('+modelines') || &modelines < 1 || ( !&modeline &&
!exists('b:modeline') )
        return -1
    endif
    let m=''
    if &modelines>line('$')
(Continue reading)


Gmane