source: issm/branches/trunk-jpl-damage/externalpackages/vim/addons/vimrc@ 13101

Last change on this file since 13101 was 13101, checked in by cborstad, 13 years ago

merged trunk-jpl through revision 13099 into branch

File size: 8.8 KB
Line 
1
2" General setup{{{1
3" ----------------------------------------------------------------------
4" Use Vim settings, rather then Vi settings (much better!).
5" This must be first, because it changes other options as a side effect.
6set nocompatible
7" UNIX special
8set shell=/bin/bash
9" jingle bells, jingle bells, hingle bells, ....
10set errorbells
11" keep 100 lines of command line history
12set history=100
13" show the cursor position all the time
14set ruler
15" display incomplete commands
16set showcmd
17" display curent mode
18set showmode
19"----------------------------------------------------------------------}}}
20" Text-Formatting, Identing, Tabbing{{{1
21" ----------------------------------------------------------------------
22" allow backspacing (to delete) over everything in insert mode
23set backspace=indent,eol,start
24" number of spaces the tab stands for
25set tabstop=3
26" number of spaces the softtab (>>) stands for
27set softtabstop=3
28" number of spaces used for (auto)indenting
29set shiftwidth=3
30" a <tab> in an indent inserts 'shiftwidth' spaces (not tabstop)
31set smarttab
32" always set autoindenting on
33set autoindent
34"smartindenting useful (use '=')
35set smartindent
36
37"base folds on markers
38set foldmethod=marker
39set foldtext=IssmFoldText()
40" -----------------------------------------------------------}}}
41" Backups {{{1
42" -----------------------------------------------------------
43" updatecount number of characters typed to cause a swap file update (0->disable)
44set uc=0
45" make no backups
46set nobackup
47" -----------------------------------------------------------}}}
48" Searching, Substituting {{{1
49" -----------------------------------------------------------
50" select case-insenitive search
51"set ignorecase
52" No ignorecase if Uppercase chars in search
53"set scs
54" change the way backslashes are used in search patterns (. instead of \.)
55set magic
56" begin search at top when EOF reached
57set wrapscan
58" jump to matches during entering the pattern
59set sm
60" do incremental searching
61set incsearch
62"highlight all matches
63set hlsearch
64" Do not toggle 'g' and 'c' with :s///gc
65set noedcompatible
66
67" use 'g'-flag when substituting (subst. all matches in that line, not only
68" first) to turn off, use g
69set gdefault
70" how command line completion works (use tab to complete the file name)
71set wildmode=list:longest,list:full
72" ignore some files for filename completion
73set wildignore=*.o,*.r,*.so,*.sl,*.tar,*.tgz
74" some filetypes got lower priority
75set su=.h,.bak,~,.o,.info,.swp,.obj
76" ----------------------------------------------------------------------}}}
77" Colors and theme {{{1
78" ----------------------------------------------------------------------
79" use 256 colors
80"set t_Co=8
81set t_Co=256
82" backgrounb color
83"set background=light
84"set background=dark
85" colorscheme
86"colorscheme issm_white
87colorscheme issm_black
88" ----------------------------------------------------------------------}}}
89
90" Mappings{{{1
91" ----------------------------------------------------------------------
92"stop highlightings when spce is pressed
93nnoremap <silent> <Space> :silent noh<Bar>echo<CR>
94
95"line numbering in flip-flop
96map num :set number!<CR>
97
98" save & "make" the current file in all modes
99map <F8> :w <Enter> :make <Enter><Enter>
100map! <F8> <ESC> :w <Enter> :make <Enter><Enter>
101
102"use paste P: re-indent and re-format at the same time
103:nnoremap <Esc>P P'[v']=
104:nnoremap <Esc>p p'[v']=
105
106" Don't use Ex mode, use Q for formatting
107map Q gq
108" ----------------------------------------------------------------------}}}
109" Autocommands {{{1
110" ----------------------------------------------------------------------
111" Only do this part when compiled with support for autocommands.
112if has("autocmd")
113
114 " Enable file type detection.
115 " Also load indent files, to automatically do language-dependent indenting.
116 filetype plugin indent on
117 "filetype plugin on
118
119 " For all text files set 'textwidth' to 78 characters.
120 autocmd FileType text setlocal textwidth=0
121
122 " When editing a file, always jump to the last known cursor position.
123 " Don't do it when the position is invalid or when inside an event handler
124 " (happens when dropping a file on gvim).
125 autocmd BufReadPost *
126 \ if line("'\"") > 0 && line("'\"") <= line("$") |
127 \ exe "normal g`\"" |
128 \ endif |
129 \ for fnum in range(1,foldlevel('.')) |
130 \ exe ":foldopen" |
131 \ endfor
132
133 "scripts must be executable
134 autocmd BufWritePost *.sh !chmod +x %
135
136endif " has("autocmd")
137" ----------------------------------------------------------------------}}}
138" Matlab special {{{1
139" ----------------------------------------------------------------------
140"" associate *.par with matlab filetype
141au BufRead,BufNewFile *.par setfiletype matlab
142au BufRead,BufNewFile *.tpl setfiletype html
143" ----------------------------------------------------------------------}}}
144" C special{{{1
145" ----------------------------------------------------------------------
146"indenting for C-code
147set cindent
148" and here some nice options for cindenting
149set cinoptions={.5s,+.5s,t0,n-2,p2s,(03s,=.5s,>1s,=1s,:1s
150" ----------------------------------------------------------------------}}}
151" TEX special{{{1
152" ----------------------------------------------------------------------
153au BufRead,BufNewFile *.tex,*.html set textwidth=100 "100 caracters max (See gq command)
154au BufRead,BufNewFile *.tex,*.html set formatoptions=cqt "automatic wraping
155au BufRead,BufNewFile *.tex,*.html set wrapmargin=0 "no margin
156au BufRead,BufNewFile *.cls setfiletype tex
157
158" OPTIONAL: Starting with Vim 7, the filetype of empty .tex files defaults to
159" 'plaintex' instead of 'tex', which results in vim-latex not being loaded.
160" The following changes the default filetype back to 'tex':
161let g:tex_flavor='latex'
162" ----------------------------------------------------------------------}}}
163" FORTRAN special{{{1
164" ----------------------------------------------------------------------
165au BufRead,BufNewFile *.src setfiletype fortran
166" ----------------------------------------------------------------------}}}
167" InsertTabWrapper{{{1
168" ----------------------------------------------------------------------
169function! InsertTabWrapper(direction)
170let col = col('.') - 1
171if !col || getline('.')[col - 1] !~ '\k'
172 return "\<tab>"
173elseif "backward" == a:direction
174 return "\<c-p>"
175else
176 return "\<c-n>"
177endif
178endfunction
179
180inoremap <tab> <c-r>=InsertTabWrapper ("forward")<cr>
181inoremap <s-tab> <c-r>=InsertTabWrapper ("backward")<cr>
182
183"source ~/.exrc
184set wildmenu
185
186"Change to directory of current file automatically
187autocmd BufEnter * lcd %:p:h
188" ----------------------------------------------------------------------}}}
189
190" Abbreviations {{{1
191" ----------------------------------------------------------------------
192func Eatchar(pat)
193 let c = nr2char(getchar())
194 return (c =~ a:pat) ? '' : c
195endfunc
196au BufRead,BufNewFile *.html iabbr <silent> H1 <h1></h1><Left><Left><Left><Left><Left><C-R>=Eatchar('\s')<CR>
197au BufRead,BufNewFile *.html iabbr <silent> H2 <h2></h2><Left><Left><Left><Left><Left><C-R>=Eatchar('\s')<CR>
198au BufRead,BufNewFile *.html iabbr <silent> H3 <h3></h3><Left><Left><Left><Left><Left><C-R>=Eatchar('\s')<CR>
199au BufRead,BufNewFile *.html iabbr <silent> CO <code></code><Left><Left><Left><Left><Left><Left><C-R>=Eatchar('\s')<CR>
200au BufRead,BufNewFile *.html iabbr <silent> PP <p></p><Left><Left><Left><Left><C-R>=Eatchar('\s')<CR>
201au BufRead,BufNewFile *.m iabbr <silent> p1 disp('');<Left><Left><Left><C-R>=Eatchar('\s')<CR>
202au BufRead,BufNewFile *.m iab <expr> p0 "disp('-------------- file: ".expand('%')." line: ".line(".")."');"
203au BufRead,BufNewFile *.c* iabbr <silent> p1 printf("\n");<Left><Left><Left><Left><Left><C-R>=Eatchar('\s')<CR>
204au BufRead,BufNewFile *.c*,*.h iabbr <silent> ER _error_("");<Left><Left><Left><C-R>=Eatchar('\s')<CR>
205au BufRead,BufNewFile *.py iabbr <silent> ER raise NameError('')<Left><Left><C-R>=Eatchar('\s')<CR>
206au BufRead,BufNewFile *.m iabbr <silent> ER error('');<Left><Left><Left><C-R>=Eatchar('\s')<CR>
207au BufRead,BufNewFile *.c* ab VV VecView(ug,PETSC_VIEWER_STDOUT_WORLD);
208au BufRead,BufNewFile *.c* ab AS _assert_();
209au BufRead,BufNewFile *.c* iab <expr> p0 "printf(\"-------------- file: ".expand('%')." line: %i\\n\",__LINE__);"
210au BufRead,BufNewFile *.c* iab <expr> pp0 "PetscSynchronizedPrintf(MPI_COMM_WORLD,\"-------------- file: ".expand('%')." line: %i\\n\",__LINE__);\nPetscSynchronizedFlush(MPI_COMM_WORLD);"
211"tex
212au BufRead,BufNewFile *.tex iab EQ
213 \\begin{equation}
214 \<CR>\end{equation}<up><C-R>=Eatchar('\s')<CR>
215au BufRead,BufNewFile *.tex iab IT
216 \\begin{itemize}
217 \<CR>\item
218 \<CR>\end{itemize}<up><C-R>=Eatchar('\s')<CR>
219au BufRead,BufNewFile *.tex iab EN
220 \\begin{enumerate}
221 \<CR>\item
222 \<CR>\end{enumerate}<up><C-R>=Eatchar('\s')<CR>
223au BufRead,BufNewFile *.tex ab (()) \left( \right)
224"}}}
225" Skeletons {{{1
226au BufNewFile letter.tex 0r ~/.vim/xtr/skeleton/letter.tex
227"}}}
Note: See TracBrowser for help on using the repository browser.