Loading ...
Sorry, an error occurred while loading the content.

Re: Newbee question:Why don't I have the syntax highlighting when editing files like *.sh *.xml,etc?

Expand Messages
  • Xi Juanjie
    syntax on should be ok. Please use :version to confirm your vim was compiled with +syntax function and keep the corresponding syntax file in vim runtime
    Message 1 of 8 , Apr 2, 2007
    • 0 Attachment
      "syntax on" should be ok.

      Please use :version to confirm your vim was compiled with "+syntax"
      function and keep the corresponding syntax file in vim runtime folder.

      Also to check if there has any "syntax off" in /etc/vim/vimrc.local.

      wangxu wrote:
      > Why don't I have the syntax highlighting when editing files like *.sh
      > *.xml,etc?
      > After commands like "syntax on",still nothing happened.
      > below is my /etc/vim/vimrc,what else should I do to turn the syntax
      > highlighting on?
      > Thanks,
      > shell.
      >
      >
      > set
      > runtimepath=~/.vim,/etc/vim,/usr/share/vim/vimfiles,/usr/share/vim/addons,/usr/share/vim/vim63,/usr/share/vim/vimfiles,/usr/share/vim/addons/after,~/.vim/after
      >
      > set nocompatible " Use Vim defaults instead of 100% vi compatibility
      > set backspace=indent,eol,start " more powerful backspacing
      >
      > set autoindent " always set autoindenting on
      > set textwidth=0 " Don't wrap lines by default
      > set viminfo='20,\"50 " read/write a .viminfo file, don't store more than
      > " 50 lines of registers
      > set history=50 " keep 50 lines of command line history
      > set ruler " show the cursor position all the time
      >
      > set
      > suffixes=.bak,~,.swp,.o,.info,.aux,.log,.dvi,.bbl,.blg,.brf,.cb,.ind,.idx,.ilg,.inx,.out,.toc
      >
      > if &term =~ "xterm-debian" || &term =~ "xterm-xfree86" || &term =~ "xterm"
      > set t_Co=16
      > set t_Sf=[3%dm
      > set t_Sb=[4%dm
      > endif
      >
      > vnoremap p <Esc>:let current_reg = @"<CR>gvdi<C-R>=current_reg<CR><Esc>
      >
      >
      > syntax on
      >
      >
      > if has("autocmd")
      > " Enabled file type detection
      > " Use the default filetype settings. If you also want to load indent files
      > " to automatically do language-dependent indenting add 'indent' as well.
      > filetype plugin on
      >
      > endif " has ("autocmd")
      >
      > augroup filetype
      > au BufRead reportbug.* set ft=mail
      > au BufRead reportbug-* set ft=mail
      > augroup END
      >
      > try
      > if filereadable('/etc/papersize')
      > let s:papersize = matchstr(system('/bin/cat /etc/papersize'), '\p*')
      > if strlen(s:papersize)
      > let &printoptions = "paper:" . s:papersize
      > endif
      > unlet! s:papersize
      > endif
      > catch /E145/
      > endtry
      >
      >
      > if filereadable("/etc/vim/vimrc.local")
      > source /etc/vim/vimrc.local
      > endif
      >
      >
      >
      > if &t_Co > 2 || has("gui_running")
      > syntax on
      > set hlsearch
      > endif
      >
      >
      >
      >
    • Peter Hodge
      Hello, Also you can use ... to see which filetype has been detected, and which syntax has been activated. regards, Peter ...
      Message 2 of 8 , Apr 2, 2007
      • 0 Attachment
        Hello,

        Also you can use

        :set ft? syntax?

        to see which filetype has been detected, and which syntax has been activated.

        regards,
        Peter



        --- Xi Juanjie <xijj@...> wrote:

        > "syntax on" should be ok.
        >
        > Please use :version to confirm your vim was compiled with "+syntax"
        > function and keep the corresponding syntax file in vim runtime folder.
        >
        > Also to check if there has any "syntax off" in /etc/vim/vimrc.local.
        >
        > wangxu wrote:
        > > Why don't I have the syntax highlighting when editing files like *.sh
        > > *.xml,etc?
        > > After commands like "syntax on",still nothing happened.
        > > below is my /etc/vim/vimrc,what else should I do to turn the syntax
        > > highlighting on?
        > > Thanks,
        > > shell.
        > >
        > >
        > > set
        > >
        >
        runtimepath=~/.vim,/etc/vim,/usr/share/vim/vimfiles,/usr/share/vim/addons,/usr/share/vim/vim63,/usr/share/vim/vimfiles,/usr/share/vim/addons/after,~/.vim/after
        > >
        > > set nocompatible " Use Vim defaults instead of 100% vi compatibility
        > > set backspace=indent,eol,start " more powerful backspacing
        > >
        > > set autoindent " always set autoindenting on
        > > set textwidth=0 " Don't wrap lines by default
        > > set viminfo='20,\"50 " read/write a .viminfo file, don't store more than
        > > " 50 lines of registers
        > > set history=50 " keep 50 lines of command line history
        > > set ruler " show the cursor position all the time
        > >
        > > set
        > >
        >
        suffixes=.bak,~,.swp,.o,.info,.aux,.log,.dvi,.bbl,.blg,.brf,.cb,.ind,.idx,.ilg,.inx,.out,.toc
        > >
        > > if &term =~ "xterm-debian" || &term =~ "xterm-xfree86" || &term =~ "xterm"
        > > set t_Co=16
        > > set t_Sf=[3%dm
        > > set t_Sb=[4%dm
        > > endif
        > >
        > > vnoremap p <Esc>:let current_reg = @"<CR>gvdi<C-R>=current_reg<CR><Esc>
        > >
        > >
        > > syntax on
        > >
        > >
        > > if has("autocmd")
        > > " Enabled file type detection
        > > " Use the default filetype settings. If you also want to load indent files
        > > " to automatically do language-dependent indenting add 'indent' as well.
        > > filetype plugin on
        > >
        > > endif " has ("autocmd")
        > >
        > > augroup filetype
        > > au BufRead reportbug.* set ft=mail
        > > au BufRead reportbug-* set ft=mail
        > > augroup END
        > >
        > > try
        > > if filereadable('/etc/papersize')
        > > let s:papersize = matchstr(system('/bin/cat /etc/papersize'), '\p*')
        > > if strlen(s:papersize)
        > > let &printoptions = "paper:" . s:papersize
        > > endif
        > > unlet! s:papersize
        > > endif
        > > catch /E145/
        > > endtry
        > >
        > >
        > > if filereadable("/etc/vim/vimrc.local")
        > > source /etc/vim/vimrc.local
        > > endif
        > >
        > >
        > >
        > > if &t_Co > 2 || has("gui_running")
        > > syntax on
        > > set hlsearch
        > > endif
        > >
        > >
        > >
        > >
        >


        Send instant messages to your online friends http://au.messenger.yahoo.com
      • A.J.Mechelynck
        ... [...] The :scriptnames command will list all scripts that have been sourced so far in the current Vim session. They are listed in the order of first
        Message 3 of 8 , Apr 3, 2007
        • 0 Attachment
          wangxu wrote:
          > Why don't I have the syntax highlighting when editing files like *.sh
          > *.xml,etc?
          > After commands like "syntax on",still nothing happened.
          > below is my /etc/vim/vimrc,what else should I do to turn the syntax
          > highlighting on?
          > Thanks,
          > shell.
          [...]

          The ":scriptnames" command will list all scripts that have been sourced so far
          in the current Vim session. They are listed in the order of first sourcing.
          When editing your vimrc, the list should include:
          - the vimrc near the top;
          - $VIMRUNTIME/syntax/vim.vim somewhere lower down. The $VIMRUNTIME variable
          will be resolved; on your system, I expect its value to be /usr/share/vim/vim70

          /etc/vim/vimrc is a strange location for a system vimrc. If the above shows
          that is wasn't sourced, try putting it at /usr/share/vim/vimrc -- if you don't
          want to move the Debian vimrc you can use a soft link:

          cd /usr/share/vim
          ln -vs /etc/vim/vimrc


          Oh, and next time you post a ":version" listing on the list, please first do
          ":language messages C" (on Unix). I know just enough Chinese to understand
          that 大 on the fourth line means "big", so I can guess that that fourth line
          probably means "Big version with GTK2 GUI. Features included (+) or not (-):"
          but the average subscriber to this list cannot even be assumed to know any
          Chinese at all.


          Best regards,
          Tony.
          --
          "All flesh is grass"
          -- Isaiah
          Smoke a friend today.
        • wangxu
          I checked with :version,it is compiled with the +syntax ,and no syntax off in /etc/vim/vimrc.local or files like that. I don t know where the syntax files
          Message 4 of 8 , Apr 3, 2007
          • 0 Attachment
            I checked with :version,it is compiled with the "+syntax",and no "syntax
            off" in /etc/vim/vimrc.local or files like that.
            I don't know where the syntax files should be,but there are syntax files
            in /usr/share/vim/vim70/syntax.
            Below is the :version result.

            :version
            VIM - Vi IMproved 7.0 (2006 May 7, compiled Jan 31 2007 17:43:00)
            包含补丁: 1-122
            编译者 jamessan@...
            大型版本 带 GTK2 图形界面。 可使用(+)与不可使用(-)的功能:
            +arabic +autocmd +balloon_eval +browse ++builtin_terms +byte_offset
            +cindent +clientserver
            +clipboard +cmdline_compl +cmdline_hist +cmdline_info +comments +cryptv
            +cscope
            +cursorshape +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
            -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_interact +xterm_clipboard -xterm_save
            系统 vimrc 文件: "$VIM/vimrc"
            用户 vimrc 文件: "$HOME/.vimrc"
            用户 exrc 文件: "$HOME/.exrc"
            系统 gvimrc 文件: "$VIM/gvimrc"
            用户 gvimrc 文件: "$HOME/.gvimrc"
            系统菜单文件: "$VIMRUNTIME/menu.vim"
            $VIM 预设值: "/usr/share/vim"






            Xi Juanjie wrote:
            > "syntax on" should be ok.
            >
            > Please use :version to confirm your vim was compiled with "+syntax"
            > function and keep the corresponding syntax file in vim runtime folder.
            >
            > Also to check if there has any "syntax off" in /etc/vim/vimrc.local.
            >
            > wangxu wrote:
            >
            >> Why don't I have the syntax highlighting when editing files like *.sh
            >> *.xml,etc?
            >> After commands like "syntax on",still nothing happened.
            >> below is my /etc/vim/vimrc,what else should I do to turn the syntax
            >> highlighting on?
            >> Thanks,
            >> shell.
            >>
            >>
            >> set
            >> runtimepath=~/.vim,/etc/vim,/usr/share/vim/vimfiles,/usr/share/vim/addons,/usr/share/vim/vim63,/usr/share/vim/vimfiles,/usr/share/vim/addons/after,~/.vim/after
            >>
            >> set nocompatible " Use Vim defaults instead of 100% vi compatibility
            >> set backspace=indent,eol,start " more powerful backspacing
            >>
            >> set autoindent " always set autoindenting on
            >> set textwidth=0 " Don't wrap lines by default
            >> set viminfo='20,\"50 " read/write a .viminfo file, don't store more than
            >> " 50 lines of registers
            >> set history=50 " keep 50 lines of command line history
            >> set ruler " show the cursor position all the time
            >>
            >> set
            >> suffixes=.bak,~,.swp,.o,.info,.aux,.log,.dvi,.bbl,.blg,.brf,.cb,.ind,.idx,.ilg,.inx,.out,.toc
            >>
            >> if &term =~ "xterm-debian" || &term =~ "xterm-xfree86" || &term =~ "xterm"
            >> set t_Co=16
            >> set t_Sf=[3%dm
            >> set t_Sb=[4%dm
            >> endif
            >>
            >> vnoremap p <Esc>:let current_reg = @"<CR>gvdi<C-R>=current_reg<CR><Esc>
            >>
            >>
            >> syntax on
            >>
            >>
            >> if has("autocmd")
            >> " Enabled file type detection
            >> " Use the default filetype settings. If you also want to load indent files
            >> " to automatically do language-dependent indenting add 'indent' as well.
            >> filetype plugin on
            >>
            >> endif " has ("autocmd")
            >>
            >> augroup filetype
            >> au BufRead reportbug.* set ft=mail
            >> au BufRead reportbug-* set ft=mail
            >> augroup END
            >>
            >> try
            >> if filereadable('/etc/papersize')
            >> let s:papersize = matchstr(system('/bin/cat /etc/papersize'), '\p*')
            >> if strlen(s:papersize)
            >> let &printoptions = "paper:" . s:papersize
            >> endif
            >> unlet! s:papersize
            >> endif
            >> catch /E145/
            >> endtry
            >>
            >>
            >> if filereadable("/etc/vim/vimrc.local")
            >> source /etc/vim/vimrc.local
            >> endif
            >>
            >>
            >>
            >> if &t_Co > 2 || has("gui_running")
            >> syntax on
            >> set hlsearch
            >> endif
            >>
            >>
            >>
            >>
            >>
            >
            >
            >
          • wangxu
            You are right.my runtimepath is wrong. I updated vim to 7.0 using apt-get, but left the old vimrc unchanged. I checked the vimrc and replaced
            Message 5 of 8 , Apr 3, 2007
            • 0 Attachment
              You are right.my runtimepath is wrong.
              I updated vim to 7.0 using apt-get, but left the old vimrc unchanged.
              I checked the vimrc and replaced /usr/share/vim/vim63 to
              /usr/share/vim/vim70,
              It is OK now.
              thank you!

              Peter Hodge wrote:
              > --- wangxu <wangxu@...> wrote:
              >
              >
              >> the results are
              >>
              >> filetype=
              >> syntax=
              >>
              >> Why could this happen?
              >>
              >
              > Not sure? Do you get any results if you type
              >
              > :au filetypedetect * *.sh
              >
              > You should see something like:
              >
              > --- Auto-Commands ---
              > filetypedetect BufNewFile
              > *.sh call SetFileTypeSH(getline(1))
              > filetypedetect BufRead
              > *.sh call SetFileTypeSH(getline(1))
              >
              > If you don't see any commands like those above, then the syntax will not work;
              > perhaps your 'runtimepath' is wrong?
              >
              > Also, check the value of 'eventignore', it might prevent the FileType detection
              > from activating:
              >
              > :set eventignore?
              >
              > should show:
              >
              > eventignore=
              >
              > regards,
              > Peter
              >
              >
              >
              >> Peter Hodge wrote:
              >>
              >>> Hello,
              >>>
              >>> Also you can use
              >>>
              >>> :set ft? syntax?
              >>>
              >>> to see which filetype has been detected, and which syntax has been
              >>>
              >> activated.
              >>
              >>> regards,
              >>> Peter
              >>>
              >>>
              >>>
              >>> --- Xi Juanjie <xijj@...> wrote:
              >>>
              >>>
              >>>
              >>>> "syntax on" should be ok.
              >>>>
              >>>> Please use :version to confirm your vim was compiled with "+syntax"
              >>>> function and keep the corresponding syntax file in vim runtime folder.
              >>>>
              >>>> Also to check if there has any "syntax off" in /etc/vim/vimrc.local.
              >>>>
              >>>> wangxu wrote:
              >>>>
              >>>>
              >>>>> Why don't I have the syntax highlighting when editing files like *.sh
              >>>>> *.xml,etc?
              >>>>> After commands like "syntax on",still nothing happened.
              >>>>> below is my /etc/vim/vimrc,what else should I do to turn the syntax
              >>>>> highlighting on?
              >>>>> Thanks,
              >>>>> shell.
              >>>>>
              >>>>>
              >>>>> set
              >>>>>
              >>>>>
              >>>>>
              > runtimepath=~/.vim,/etc/vim,/usr/share/vim/vimfiles,/usr/share/vim/addons,/usr/share/vim/vim63,/usr/share/vim/vimfiles,/usr/share/vim/addons/after,~/.vim/after
              >
              >>>
              >>>
              >>>>> set nocompatible " Use Vim defaults instead of 100% vi compatibility
              >>>>> set backspace=indent,eol,start " more powerful backspacing
              >>>>>
              >>>>> set autoindent " always set autoindenting on
              >>>>> set textwidth=0 " Don't wrap lines by default
              >>>>> set viminfo='20,\"50 " read/write a .viminfo file, don't store more than
              >>>>> " 50 lines of registers
              >>>>> set history=50 " keep 50 lines of command line history
              >>>>> set ruler " show the cursor position all the time
              >>>>>
              >>>>> set
              >>>>>
              >>>>>
              >>>>>
              > suffixes=.bak,~,.swp,.o,.info,.aux,.log,.dvi,.bbl,.blg,.brf,.cb,.ind,.idx,.ilg,.inx,.out,.toc
              >
              >>>
              >>>
              >>>>> if &term =~ "xterm-debian" || &term =~ "xterm-xfree86" || &term =~
              >>>>>
              >> "xterm"
              >>
              >>>>> set t_Co=16
              >>>>> set t_Sf=[3%dm
              >>>>> set t_Sb=[4%dm
              >>>>> endif
              >>>>>
              >>>>> vnoremap p <Esc>:let current_reg = @"<CR>gvdi<C-R>=current_reg<CR><Esc>
              >>>>>
              >>>>>
              >>>>> syntax on
              >>>>>
              >>>>>
              >>>>> if has("autocmd")
              >>>>> " Enabled file type detection
              >>>>> " Use the default filetype settings. If you also want to load indent
              >>>>>
              >> files
              >>
              >>>>> " to automatically do language-dependent indenting add 'indent' as well.
              >>>>> filetype plugin on
              >>>>>
              >>>>> endif " has ("autocmd")
              >>>>>
              >>>>> augroup filetype
              >>>>> au BufRead reportbug.* set ft=mail
              >>>>> au BufRead reportbug-* set ft=mail
              >>>>> augroup END
              >>>>>
              >>>>> try
              >>>>> if filereadable('/etc/papersize')
              >>>>> let s:papersize = matchstr(system('/bin/cat /etc/papersize'), '\p*')
              >>>>> if strlen(s:papersize)
              >>>>> let &printoptions = "paper:" . s:papersize
              >>>>> endif
              >>>>> unlet! s:papersize
              >>>>> endif
              >>>>> catch /E145/
              >>>>> endtry
              >>>>>
              >>>>>
              >>>>> if filereadable("/etc/vim/vimrc.local")
              >>>>> source /etc/vim/vimrc.local
              >>>>> endif
              >>>>>
              >>>>>
              >>>>>
              >>>>> if &t_Co > 2 || has("gui_running")
              >>>>> syntax on
              >>>>> set hlsearch
              >>>>> endif
              >>>>>
              >>>>>
              >>>>>
              >>>>>
              >>>>>
              >>>>>
              >>> Send instant messages to your online friends http://au.messenger.yahoo.com
              >>>
              >>>
              >>>
              >>>
              >>
              >
              >
              > Send instant messages to your online friends http://au.messenger.yahoo.com
              >
              >
              >
            • Tobia
              ... It is a very intuitive location. In Debian all system-wide configuration files are in /etc/ / ... That would explain the problem. To the
              Message 6 of 8 , Apr 3, 2007
              • 0 Attachment
                A.J.Mechelynck wrote:
                > /etc/vim/vimrc is a strange location for a system vimrc

                It is a very intuitive location. In Debian all system-wide
                configuration files are in /etc/<package name>/

                > I know just enough Chinese to understand that 大 on the fourth line
                > means "big", so I can guess that that fourth line probably means "Big
                > version with GTK2 GUI. Features included (+) or not (-):"

                That would explain the problem. To the original poster: try adding the
                following line to /etc/vim/gvimrc.local (create it if needed)

                source /etc/vim/vimrc


                Tobia
              • wangxu
                Sure: ) I will remeber that next time I post something. I v solved the problem. My runtimepath is wrong. I updated vim to 7.0 using apt-get, but left the
                Message 7 of 8 , Apr 4, 2007
                • 0 Attachment
                  Sure: ) I will remeber that next time I post something.
                  I'v solved the problem. My runtimepath is wrong.
                  I updated vim to 7.0 using apt-get, but left the old vimrc unchanged.
                  I checked the vimrc and replaced /usr/share/vim/vim63 to
                  /usr/share/vim/vim70,
                  It is OK now.
                  Thank you All: )

                  A.J.Mechelynck wrote:
                  > wangxu wrote:
                  >> Why don't I have the syntax highlighting when editing files like *.sh
                  >> *.xml,etc?
                  >> After commands like "syntax on",still nothing happened.
                  >> below is my /etc/vim/vimrc,what else should I do to turn the syntax
                  >> highlighting on?
                  >> Thanks,
                  >> shell.
                  > [...]
                  >
                  > The ":scriptnames" command will list all scripts that have been
                  > sourced so far in the current Vim session. They are listed in the
                  > order of first sourcing. When editing your vimrc, the list should
                  > include:
                  > - the vimrc near the top;
                  > - $VIMRUNTIME/syntax/vim.vim somewhere lower down. The $VIMRUNTIME
                  > variable will be resolved; on your system, I expect its value to be
                  > /usr/share/vim/vim70
                  >
                  > /etc/vim/vimrc is a strange location for a system vimrc. If the above
                  > shows that is wasn't sourced, try putting it at /usr/share/vim/vimrc
                  > -- if you don't want to move the Debian vimrc you can use a soft link:
                  >
                  > cd /usr/share/vim
                  > ln -vs /etc/vim/vimrc
                  >
                  >
                  > Oh, and next time you post a ":version" listing on the list, please
                  > first do ":language messages C" (on Unix). I know just enough Chinese
                  > to understand that 大 on the fourth line means "big", so I can guess
                  > that that fourth line probably means "Big version with GTK2 GUI.
                  > Features included (+) or not (-):" but the average subscriber to this
                  > list cannot even be assumed to know any Chinese at all.
                  >
                  >
                  > Best regards,
                  > Tony.
                Your message has been successfully submitted and would be delivered to recipients shortly.