home *** CD-ROM | disk | FTP | other *** search
/ vim.ftp.fu-berlin.de / 2015-02-03.vim.ftp.fu-berlin.de.tar / vim.ftp.fu-berlin.de / mac / vim55rt.sit / runtime / vimrc_example.vim < prev   
Encoding:
Text File  |  1999-09-25  |  3.4 KB  |  104 lines  |  [TEXT/VIM!]

  1. " An example for a vimrc file.
  2. "
  3. " Maintainer:    Bram Moolenaar <Bram@vim.org>
  4. " Last change:    1999 Sep 09
  5. "
  6. " To use it, copy it to
  7. "     for Unix and OS/2:  ~/.vimrc
  8. "             for Amiga:  s:.vimrc
  9. "  for MS-DOS and Win32:  $VIM\_vimrc
  10.  
  11. set nocompatible    " Use Vim defaults (much better!)
  12. set bs=2        " allow backspacing over everything in insert mode
  13. set ai            " always set autoindenting on
  14. set backup        " keep a backup file
  15. set viminfo='20,\"50    " read/write a .viminfo file, don't store more
  16.             " than 50 lines of registers
  17. set history=50        " keep 50 lines of command line history
  18. set ruler        " show the cursor position all the time
  19.  
  20. " For Win32 GUI: remove 't' flag from 'guioptions': no tearoff menu entries
  21. " let &guioptions = substitute(&guioptions, "t", "", "g")
  22.  
  23. " Don't use Ex mode, use Q for formatting
  24. map Q gq
  25.  
  26. " Make p in Visual mode replace the selected text with the "" register.
  27. vnoremap p <Esc>:let current_reg = @"<CR>gvdi<C-R>=current_reg<CR><Esc>
  28.  
  29. " Switch syntax highlighting on, when the terminal has colors
  30. " Also switch on highlighting the last used search pattern.
  31. if &t_Co > 2 || has("gui_running")
  32.   syntax on
  33.   set hlsearch
  34. endif
  35.  
  36. " Only do this part when compiled with support for autocommands.
  37. if has("autocmd")
  38.  
  39.  " In text files, always limit the width of text to 78 characters
  40.  autocmd BufRead *.txt set tw=78
  41.  
  42.  augroup cprog
  43.   " Remove all cprog autocommands
  44.   au!
  45.  
  46.   " When starting to edit a file:
  47.   "   For C and C++ files set formatting of comments and set C-indenting on.
  48.   "   For other files switch it off.
  49.   "   Don't change the order, it's important that the line with * comes first.
  50.   autocmd FileType *      set formatoptions=tcql nocindent comments&
  51.   autocmd FileType c,cpp  set formatoptions=croql cindent comments=sr:/*,mb:*,el:*/,://
  52.  augroup END
  53.  
  54.  augroup gzip
  55.   " Remove all gzip autocommands
  56.   au!
  57.  
  58.   " Enable editing of gzipped files
  59.   " set binary mode before reading the file
  60.   autocmd BufReadPre,FileReadPre    *.gz,*.bz2 set bin
  61.   autocmd BufReadPost,FileReadPost    *.gz call GZIP_read("gunzip")
  62.   autocmd BufReadPost,FileReadPost    *.bz2 call GZIP_read("bunzip2")
  63.   autocmd BufWritePost,FileWritePost    *.gz call GZIP_write("gzip")
  64.   autocmd BufWritePost,FileWritePost    *.bz2 call GZIP_write("bzip2")
  65.   autocmd FileAppendPre            *.gz call GZIP_appre("gunzip")
  66.   autocmd FileAppendPre            *.bz2 call GZIP_appre("bunzip2")
  67.   autocmd FileAppendPost        *.gz call GZIP_write("gzip")
  68.   autocmd FileAppendPost        *.bz2 call GZIP_write("bzip2")
  69.  
  70.   " After reading compressed file: Uncompress text in buffer with "cmd"
  71.   fun! GZIP_read(cmd)
  72.     let ch_save = &ch
  73.     set ch=2
  74.     execute "'[,']!" . a:cmd
  75.     set nobin
  76.     let &ch = ch_save
  77.     execute ":doautocmd BufReadPost " . expand("%:r")
  78.   endfun
  79.  
  80.   " After writing compressed file: Compress written file with "cmd"
  81.   fun! GZIP_write(cmd)
  82.     if rename(expand("<afile>"), expand("<afile>:r")) == 0
  83.       execute "!" . a:cmd . " <afile>:r"
  84.     endif
  85.   endfun
  86.  
  87.   " Before appending to compressed file: Uncompress file with "cmd"
  88.   fun! GZIP_appre(cmd)
  89.     execute "!" . a:cmd . " <afile>"
  90.     call rename(expand("<afile>:r"), expand("<afile>"))
  91.   endfun
  92.  
  93.  augroup END
  94.  
  95.  " This is disabled, because it changes the jumplist.  Can't use CTRL-O to go
  96.  " back to positions in previous files more than once.
  97.  if 0
  98.   " When editing a file, always jump to the last cursor position.
  99.   " This must be after the uncompress commands.
  100.    autocmd BufReadPost * if line("'\"") && line("'\"") <= line("$") | exe "normal `\"" | endif
  101.  endif
  102.  
  103. endif " has("autocmd")
  104.