Syntax error from cshrc, but not showing line number

Hi,

I have been using ksh till now but was forced to use tcsh from last few days. I am getting a gvimrc error which says "set: Syntax error". What makes this pesky is that it is not showing which line number is the error from. How do I get the line number of the error?

Also, I am using the same gvimrc as I used in ksh, where comments were done using double quotes ("). But here all those are not taken as comments. So I want to know whether only # can be used to comment lines in tcsh ?

Hi, welcome to the forums.

You probably have a quotation errror/typo near a place you set a variable.
Try:

$SHELL -x ./scriptname

To get an idea at what place it stops executing code.

If you need more detailed help, please provide the script in code tags.

Hope this helps

EDIT:
No, # work as comments in all shells

1 Like

Hi Sea,
Thank you very much for the reply. I used your technique and found out that the syntax error is happening here :

set history=1000
set browsedir=buffer
set clipboard+=unnamed
set: Syntax Error.

I have no idea why this error is here because I've not touched this part and used to work fine in ksh.

(And sorry about code tags, I'm being notified that I'm allowed to post it like that once I have at least 5 posts. I'm not posting full gvimrc code as this CODE tag feature is still not enabled for me)

Was it csh where one needed spaces in between to set a variable, or was that ksh too?
Try at least toq quote the appending to clipboard: set clipboard+=" unnamed"
Other than that i'm too inexperienced with ksh.

Hope this helps

The above code was working good in ksh. All my problems are in tcsh.
Just tried the modification you suggested too, but didn't work.

Why say more, even syn on is also not working in tcsh, as shell says "Command not found".

So is the double quote used as comment in gvimrc. Throwing unmatched " error.

---------- Post updated at 06:11 PM ---------- Previous update was at 06:00 PM ----------

This my .gvimrc code

syn on
# general

set history=1000        # lines of Ex-mode commands, search history
set browsedir=buffer    # use directory of the related buffer for file browser
set clipboard+=" unnamed"  # use clipboard register '*' for all y, d, c, p ops
set viminfo+=!          # make sure it can save viminfo
set isk+=$,%,#,-        # none of these should be word dividers
set confirm             # raise a dialog confirm whether save changed buffer
set fenc=utf-8          # default fileencoding
set fencs=utf-8,ucs-bom,euc-jp,gb18030,gbk,gb2312,cp936
map Q gq
# do not use Ex-mode, use Q for formatting
set columns=151
set lines=38
" path/backup
set nobackup

" Set tabsize to 4 and replace tabs with spaces
set shiftwidth=2
set tabstop=2
set expandtab
set smarttab
set sm
"set guioptions-=T


" Text Formatting/Layout

set ai                  " autoindent
set si                  " smartindent
set cindent             " do C-style indenting
set fo=tcrqn            " see help (complex)
set complete=.,b,d,k,u,w,
  " Enable file type detection.
  " Use the default filetype settings, so that mail gets 'tw' set to 72,
  " 'cindent' is on in C files, etc.
  " Also load indent files, to automatically do language-dependent indenting.
set wrap


" visual cues
set showmatch           " show matching paren
set hlsearch          " do not highlight searched for phrases

set scrolloff=5         " minimal number of screen lines to keep above/below the cursor
set novisualbell        " use visual bell instead of beeping
set noerrorbells        " do not make noise
set listchars=tab:\|\ ,trail:.,extends:>,precedes:<,eol:$ " how :set list show

" Pressing < or > will let you indent/unident selected lines
vnoremap < <gv
vnoremap > >gv

" Set the font to 'Courier New' 'Regular' 'Size=10'
set guifont=monospace\ 12


" Vim UI
set selectmode=mouse,key      "select both with the mouse and shifted arrow key
set syntax=on                 " set syntax highlighting on
set linespace=0         " space it out a little more (easier to read)
set wildmenu            " type :h and press <Tab> to look what happens
set ruler               " always show current position along the bottom
set cmdheight=2         " use 2 screen lines for command-line
set lazyredraw          " do not redraw while executing macros (much faster)
set hid                 " allow to change buffer without saving
set backspace=2         " make backspace work normal
" set whichwrap+=<,>,h,l  " allow backspace and cursor keys to wrap
set mouse=a             " use mouse in all modes
set shortmess=atI       " shorten messages to avoid 'press a key' prompt
set report=0            " tell us when anything is changed via :...
set fillchars=vert:\ ,stl:\ ,stlnc:\
                        " make the splitters between windows be blank
                        "
"set cursorcolumn " highlight the current column
set cursorline " highlight current line
set incsearch " BUT do highlight as you type you search phrase
set laststatus=2 " always show the status line

" set list " we don't want to show tabs/space, to ensure we get them out of my files

set matchtime=5 " how many tenths of a second to blink matching brackets for
" set nohlsearch " do not highlight searched for phrases

set nostartofline " leave my cursor where it was
set nu
set numberwidth=5 " We are good up to 99999 lines
set showcmd " show the command being typed

" colors
"Try to load happy hacking teal colour scheme
"I copy this to ~/.vim/colors/hhteal.vim

"silent! colorscheme torte
"silent! colorscheme blue
"//"if exists("colors_name") == 0
"//"    "Otherwise modify the defaults appropriately
"//"
"//"    "background set to dark in .vimrc
"//"    "So pick appropriate defaults.
"//"    hi Normal     guifg=gray guibg=black
"//"    hi Visual     gui=none guifg=black guibg=yellow
"//"
"//"    "The following removes bold from all highlighting
"//"    "as this is usually rendered badly for me. Note this
"//"    "is not done in .vimrc because bold usually makes
"//"    "the colour brighter on terminals and most terminals
"//"    "allow one to keep the new colour while turning off
"//"    "the actual bolding.
"//"
"//"    " Steve Hall wrote this function for me on vim@vim.org
"//"    " See :help attr-list for possible attrs to pass
"//"    function! Highlight_remove_attr(attr)
"//"        " save selection registers
"//"        new
"//"        silent! put
"//"
"//"        " get current highlight configuration
"//"        redir @x
"//"        silent! highlight
"//"        redir END
"//"        " open temp buffer
"//"        new
"//"        " paste in
"//"        silent! put x
"//"
"//"        " convert to vim syntax (from Mkcolorscheme.vim,
"//"        "   Mkcolorscheme.vim - Help write colorscheme files from existing settings : vim online)
"//         delete empty,"links" and cleared" lines
"//"        silent! g/^$\| links \| cleared/d
"//"        " join any lines wrapped by the highlight command output
"//"        silent! %s/\n \+/ /
"//"        " remove the xxx's
"//"        silent! %s/ xxx / /
"//"        " add highlight commands
"//"        silent! %s/^/highlight /
"//"        " protect spaces in some font names
"//"        silent! %s/font=\(.*\)/font='\1'/
"//"
"//"         substitute bold with NONE"
"//"        execute 'silent! %s/' . a:attr . '\([\w,]*\)/NONE\1/geI'
"//"        " yank entire buffer
"//"        normal ggVG
"//"        " copy
"//"        silent! normal "xy
"//"        " run
"//"        execute @x
"//"
"//"        " remove temp buffer
"//"        bwipeout!
"//"
"//"        " restore selection registers
"//"        silent! normal ggVGy
"//"        bwipeout!
"//"    endfunction
"//"    autocmd BufNewFile,BufRead * call Highlight_remove_attr("bold")
"//"    " Note adding ,Syntax above messes up the syntax loading
"//"    " See :help syntax-loading for more info
"//"endif
highlight Pmenu guibg=yellow guifg=black
highlight PmenuSel guibg=white guifg=black

" Spell check
function! ToggleSpell()
    if !exists("b:spell")
        setlocal spell spelllang=en_gb
        let b:spell = 1
    else
        setlocal nospell
        unlet b:spell
    endif
endfunction


" Warn whenever text exceeds 78 columns.
" let w:m1=matchadd('Search', '\%<79v.\%>78v', -1)
" let w:m2=matchadd('ErrorMsg', '\%>78v.\+', -1)
set visualbell
" Map keys for user frendly shortcuts
map <C-Tab> <Esc>:tabn<CR>
imap <C-Tab> <Esc>:tabn<CR>
map <C-S-Tab> <Esc>:tabp<CR>
imap <C-S-Tab> <Esc>:tabp<CR>

And this is what the current status is :

[rpillai@mfu-blr-33:/usr2/rpillai]% $SHELL -x .gvimrc
syn on
syn: Command not found.
set history=1000
set browsedir=buffer
set clipboard+= unnamed
set: Syntax Error.

Again sorry about code tag. I'm still not able to use it.

Of course you are able to use code tags!
You are (afiak, should) not able to post URLS though...

A quote " is not a comment # .
For like every section information, you're doing a comment that starts with a quote, and therefor is taken as an open string, which requires closing quotes.
Thus resulting in any proper code in between to cause errors since open quotes break the syntax.

But me dont know gvim anyway, so i cannot be of help with this syntax, sorry and good luck.
But i'd rather have a serious investigation towards:

syn on
syn: Command not found.

Have you installed it?

hth

.gvimrc sounds like an initialization file for vim and not a shell script. I'm almost certain you don't want to source or run it from the command line.

1 Like

Hi.

I don't use gvim, but I use vim extensively. My .vimrc works in all shells that I have tried bash, ksh, tcsh, zsh, etc. I'm guessing that you are copying or creating the .vimrc lines with shell commands. Here is my .vimrc:

" .vimrc file
" $Id$
" Use vim to read this file, cat, etc., will
" not present an intelligible view.
"
syntax off
" set expandtab
set autoindent
set shiftwidth=4
set showmatch
set tabstop=4
set wrapmargin=15
map  i"eea"e
map 
e    !Gmy-spell

if has("autocmd")
  " When editing a file, always jump to the last known cursor position.
  " Don't do it when the position is invalid or when inside an event handler
  " (happens when dropping a file on gvim).
  autocmd BufReadPost *
  \ if line("'\"") > 0 && line("'\"") <= line("$") |
  \   exe "normal g`\"" |
  \ endif
endif " has("autocmd")

In the vim context, double quotes at the beginning of a line marks a comment.

We would need to know more about how you are creating and using .vimrc to help. I think the "set" error is because somehow tcsh is seeing the command, not vim, and set is how tcsh places values in variables.

Best wishes ... cheers, drl

Edit 1: In other words, exactly as neutronscott described.

1 Like

sea,
" can be used to comment in .gvimrc file. I have used the above posted code as such in ksh, as I've said earlier and it worked fine. And there are pages online which explains the same too. I didn't understand when you asked "Have you installed it?". If you are talking about gvim, it is already installed in the (company) server and I just needed to set path to point to the installation area, which I've done in .cshrc file.

neutronscott,
It is indeed an intialization file and is sourced from .cshrc or .profile file generally. I was running it from command line for debug purposes because I was getting syntax errors from the file. Otherwise it is automatically sourced. Thanks for the response though.

No, it's generally loaded from within vim since the shell doesn't understand that language. Do you also run perl code from the command-line without invoking perl?

mute@tiny:~$ print qq=Did you say "Hello?"\n=;
Warning: unknown mime-type for "qq=Did" -- using "application/octet-stream"
Warning: unknown mime-type for "you" -- using "application/octet-stream"
Warning: unknown mime-type for "say" -- using "application/octet-stream"
Warning: unknown mime-type for "Hello?n=" -- using "application/octet-stream"
Error: no such file "qq=Did"
Error: no such file "you"
Error: no such file "say"
Error: no such file "Hello?n="
mute@tiny:~$ perl -e 'print qq=Did you say "Hello?"\n=;'
Did you say "Hello?"

See how perl code works in perl, but not in bash?

Same thing with your gvimrc initialization file. I promise.

1 Like

Thanks neutronscott and drl!!

I had committed the blunder of trying to source .gvimrc from .cshrc. Actually I had copied it from one of my colleagues and somehow the code was there like that. Though I remember that gvimrc was never sourced from my previous kshrc, it somehow didn't dawn to me until I read your comments (even after neutronscott's first comment).

So bottom line "Never source rc files from another file. They are executed automatically". This applies to .kshrc/.cshrc etc too, I suppose.

Thanks sea, neutronscott, drl for the epiphany!! You guys are awesome.

Well, you are welcome to source a .bashrc from bash to update your configuration without restarting a terminal or login session.

Just like I'm sure you can :source ~/.vimrc or the like from within Vim.

Just don't mix them up! :slight_smile:

1 Like