set nocompatible	" Use Vim defaults (much better!)
set bs=2		" allow backspacing over everything in insert mode
"set ai			" always set autoindenting on
"set backup		" keep a backup file
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

" Only do this part when compiled with support for autocommands
if has("autocmd")
  " In text files, always limit the width of text to 78 characters
  autocmd BufRead *.txt set tw=78
  " When editing a file, always jump to the last cursor position
  autocmd BufReadPost * if line("'\"") | exe "'\"" | endif
endif

" Don't use Ex mode, use Q for formatting
map Q gq

" 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

if has("autocmd")
 augroup cprog
  " Remove all cprog autocommands
  au!

  " When starting to edit a file:
  "   For C and C++ files set formatting of comments and set C-indenting on.
  "   For other files switch it off.
  "   Don't change the order, it's important that the line with * comes first.
  autocmd FileType *      set formatoptions=tcql nocindent comments&
  autocmd FileType c,cpp  set formatoptions=croql cindent comments=sr:/*,mb:*,el:*/,://
 augroup END

 augroup gzip
  " Remove all gzip autocommands
  au!

  " Enable editing of gzipped files
  "	  read:	set binary mode before reading the file
  "		uncompress text in buffer after reading
  "	 write:	compress file after writing
  "	append:	uncompress file, append, compress file
  autocmd BufReadPre,FileReadPre	*.gz set bin
  autocmd BufReadPost,FileReadPost	*.gz let ch_save = &ch|set ch=2
  autocmd BufReadPost,FileReadPost	*.gz '[,']!gunzip
  autocmd BufReadPost,FileReadPost	*.gz set nobin
  autocmd BufReadPost,FileReadPost	*.gz let &ch = ch_save|unlet ch_save
  autocmd BufReadPost,FileReadPost	*.gz execute ":doautocmd BufReadPost " . expand("%:r")

  autocmd BufWritePost,FileWritePost	*.gz !mv <afile> <afile>:r
  autocmd BufWritePost,FileWritePost	*.gz !gzip <afile>:r

  autocmd FileAppendPre			*.gz !gunzip <afile>
  autocmd FileAppendPre			*.gz !mv <afile>:r <afile>
  autocmd FileAppendPost		*.gz !mv <afile> <afile>:r
  autocmd FileAppendPost		*.gz !gzip <afile>:r
 augroup END

 augroup bzip2
  " Remove all bzip2 autocommands
  au!

  " Enable editing of bzip2ed files
  "	  read:	set binary mode before reading the file
  "		uncompress text in buffer after reading
  "	 write:	compress file after writing
  "	append:	uncompress file, append, compress file
  autocmd BufReadPre,FileReadPre	*.bz2 set bin
  autocmd BufReadPost,FileReadPost	*.bz2 let ch_save = &ch|set ch=2
  autocmd BufReadPost,FileReadPost	*.bz2 '[,']!bunzip2
  autocmd BufReadPost,FileReadPost	*.bz2 set nobin
  autocmd BufReadPost,FileReadPost	*.bz2 let &ch = ch_save|unlet ch_save
  autocmd BufReadPost,FileReadPost	*.bz2 execute ":doautocmd BufReadPost " . expand("%:r")

  autocmd BufWritePost,FileWritePost	*.bz2 !mv <afile> <afile>:r
  autocmd BufWritePost,FileWritePost	*.bz2 !bzip2 <afile>:r

  autocmd FileAppendPre			*.bz2 !bunzip2 <afile>
  autocmd FileAppendPre			*.bz2 !mv <afile>:r <afile>
  autocmd FileAppendPost		*.bz2 !mv <afile> <afile>:r
  autocmd FileAppendPost		*.bz2 !bzip2 <afile>:r
 augroup END
endif

if &term=="xterm"
     set t_Co=8
     set t_Sb=^[4%dm
     set t_Sf=^[3%dm
endif

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set dict=/usr/share/dict/words

if &t_Co > 2 || has("gui_running")
  highlight Normal guibg=black guifg=white
endif

if &term=="kon" || &term=="linux" || &term=="jfbterm"
  set bg=dark
  "set bg=light
  syntax on
endif

if has("gui_running")
if $LANG=~"ja*"
   set fileencoding=japan
   "set kp=jman
   if has("perl")
        source $VIMRUNTIME/macros/jcode2.vim
   endif
   set guifontset=-misc-fixed-medium-r-normal--14-130-75-75-c-140-jisx0208.1983-0,
    \-misc-fixed-medium-r-normal--14-130-75-75-c-70-jisx0201.1976-0
endif
else
   if &term=="kterm" || &term=="rxvt" || &term=="jfbterm" || &term=="kon"
      set fileencoding=japan
      "set kp=jman
      if has("perl")
         source $VIMRUNTIME/macros/jcode2.vim
      endif
   endif
endif   

"
"set fileencoding=japan
"set guifontset=-misc-fixed-medium-r-normal--14-130-75-75-c-140-jisx0208.1983-0,
"\-misc-fixed-medium-r-normal--14-130-75-75-c-70-jisx0201.1976-0
"set kp=jman
"
"set nobackup
"set notitle
"set showmode
"set showcmd
"set tabstop=4
"set shiftwidth=4
"set expandtab
"set scrolloff=4
"set winheight=12
"set incsearch
"set novisualbell
"set complete=.,w,b,u,i
