We Recommend

bash Cookbook: Solutions and Examples for bash Users bash Cookbook: Solutions and Examples for bash Users
bash Cookbook teaches shell scripting the way Unix masters practice the craft. It presents a variety of recipes and tricks for all levels of shell programmers so that anyone can become a proficient user of the most common Unix shell -- the bash shell -- and cygwin or other popular Unix emulation packages.


Posted By

mbadran on 06/16/08


Tagged

Shell configuration vim


Versions (?)


Who likes this?

2 people have marked this snippet as a favorite

Juanje
alexxx


My .vimrc


Published in: Bash 


Based on Bram Moolenaar's example .vimrc.

  1. "let mysyntaxfile="~/.syntax.vim"
  2.  
  3. set nocompatible " Use Vim defaults (much better!)
  4. set bs=2 " allow backspacing over everything in insert mode
  5. set ai " always set autoindenting on
  6. " set backup " keep a backup file
  7. set viminfo='20,\"50 " read/write a .viminfo file, don't store more
  8. " than 50 lines of registers
  9. set history=50 " keep 50 lines of command line history
  10. set ruler " show the cursor position all the time
  11.  
  12. " Only do this part when compiled with support for autocommands
  13. if has("autocmd")
  14. " In text files, always limit the width of text to 78 characters
  15. autocmd BufRead *.txt set tw=78
  16. " When editing a file, always jump to the last cursor position
  17. autocmd BufReadPost * if line("'\"") | exe "'\"" | endif
  18. endif
  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. "----- set up the stuff for color highlighing in an xterm
  27. if $COLORTERM=="" && &term!="xterm-color" && &term!="linux"
  28. if has("terminfo")
  29. set t_Co=16
  30. set t_Sf=[3%p1%dm
  31. set t_Sb=[4%p1%dm
  32. set t_vb=
  33. else
  34. set t_Co=16
  35. set t_Sf=[3%dm
  36. set t_Sb=[4%dm
  37. set t_vb=
  38. endif
  39. endif
  40.  
  41. " Switch syntax highlighting on, when the terminal has colors
  42. " Also switch on highlighting the last used search pattern.
  43. if &t_Co > 2 || has("gui_running")
  44. "syntax on
  45. set hlsearch
  46. endif
  47.  
  48.  
  49. if has("autocmd")
  50. augroup cprog
  51. " Remove all cprog autocommands
  52. au!
  53.  
  54. " When starting to edit a file:
  55. " For C and C++ files set formatting of comments and set C-indenting on.
  56. " For other files switch it off.
  57. " Don't change the order, it's important that the line with * comes first.
  58. autocmd FileType * set formatoptions=tcql nocindent comments&
  59. autocmd FileType c,cpp set formatoptions=croql cindent comments=sr:/*,mb:*,el:*/,://
  60. augroup END
  61.  
  62. augroup gzip
  63. " Remove all gzip autocommands
  64. au!
  65.  
  66. " Enable editing of gzipped files
  67. " read: set binary mode before reading the file
  68. " uncompress text in buffer after reading
  69. " write: compress file after writing
  70. " append: uncompress file, append, compress file
  71. autocmd BufReadPre,FileReadPre *.gz set bin
  72. autocmd BufReadPost,FileReadPost *.gz let ch_save = &ch|set ch=2
  73. autocmd BufReadPost,FileReadPost *.gz '[,']!gunzip
  74. autocmd BufReadPost,FileReadPost *.gz set nobin
  75. autocmd BufReadPost,FileReadPost *.gz let &ch = ch_save|unlet ch_save
  76. autocmd BufReadPost,FileReadPost *.gz execute ":doautocmd BufReadPost " . expand("%:r")
  77.  
  78. autocmd BufWritePost,FileWritePost *.gz !mv <afile> <afile>:r
  79. autocmd BufWritePost,FileWritePost *.gz !gzip <afile>:r
  80.  
  81. autocmd FileAppendPre *.gz !gunzip <afile>
  82. autocmd FileAppendPre *.gz !mv <afile>:r <afile>
  83. autocmd FileAppendPost *.gz !mv <afile> <afile>:r
  84. autocmd FileAppendPost *.gz !gzip <afile>:r
  85. augroup END
  86. endif
  87.  
  88.  
  89. """"""""""""""""""""
  90. " activate mouse
  91. " set mouse=a
  92.  
  93. set background=dark
  94.  
  95. " show matching parantheses etc.
  96. set showmatch
  97.  
  98. " show the current cursor coordinates
  99. set ruler
  100.  
  101. " show the mode "insert" etc.
  102. set showmode
  103.  
  104. " set the text width to 78
  105. set tw=78
  106.  
  107. " set the wrap margin to start wrapping from 10 characters from the right
  108. set wm=10
  109.  
  110. """"""""""""""""""""
  111. " reformat the document for tab size 3
  112. ret 3
  113. set expandtab "replaces all tabs with spaces
  114.  
  115. " key remappings
  116. map <C-j> gqj
  117. map <C-k> vipgq
  118. map t {V}gq
  119. map T gqjj
  120. map f o <Esc>
  121. map F O <Esc>
  122.  
  123. autocmd BufRead *.cpp set cindent smartindent tw=1000
  124. autocmd BufRead *.php set cindent smartindent tw=1000
  125. autocmd BufRead *.sh set cindent smartindent tw=1000
  126. set autoindent
  127.  
  128. " set the c indent to 3 spaces
  129. set cino=>3
  130.  
  131. " syntax highlighting on
  132. "syntax on
  133.  
  134. " set the syntax highlighting buffer
  135. let c_minlines=0
  136.  
  137. set makeprg=make
  138.  
  139. """ more configs
  140. " set nu "sets line numbers
  141. " source mswin.vim
  142.  
  143. " Colour syntax settings
  144. set t_Co=8
  145. set t_Sb=[4%p1%d;1m
  146. set t_Sf=[3%p1%d;1m

Report this snippet 

You need to login to post a comment.