source: issm/trunk-jpl/externalpackages/vim/addons/vimrc@ 13344

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

CHG: get svn to ignore some files.

File size: 8.9 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" make update: nice for longer documents
102map <F7> :w <Enter> :make update <Enter><Enter>
103map! <F7> <ESC> :w <Enter> :make update <Enter><Enter>
104
105
106"use paste P: re-indent and re-format at the same time
107:nnoremap <Esc>P P'[v']=
108:nnoremap <Esc>p p'[v']=
109
110" Don't use Ex mode, use Q for formatting
111map Q gq
112" ----------------------------------------------------------------------}}}
113" Autocommands {{{1
114" ----------------------------------------------------------------------
115" Only do this part when compiled with support for autocommands.
116if has("autocmd")
117
118 " Enable file type detection.
119 " Also load indent files, to automatically do language-dependent indenting.
120 filetype plugin indent on
121 "filetype plugin on
122
123 " For all text files set 'textwidth' to 78 characters.
124 autocmd FileType text setlocal textwidth=0
125
126 " When editing a file, always jump to the last known cursor position.
127 " Don't do it when the position is invalid or when inside an event handler
128 " (happens when dropping a file on gvim).
129 autocmd BufReadPost *
130 \ if line("'\"") > 0 && line("'\"") <= line("$") |
131 \ exe "normal g`\"" |
132 \ endif |
133 \ for fnum in range(1,foldlevel('.')) |
134 \ exe ":foldopen" |
135 \ endfor
136
137 "scripts must be executable
138 autocmd BufWritePost *.sh !chmod +x %
139
140endif " has("autocmd")
141" ----------------------------------------------------------------------}}}
142" Matlab special {{{1
143" ----------------------------------------------------------------------
144"" associate *.par with matlab filetype
145au BufRead,BufNewFile *.par setfiletype matlab
146au BufRead,BufNewFile *.tpl setfiletype html
147" ----------------------------------------------------------------------}}}
148" C special{{{1
149" ----------------------------------------------------------------------
150"indenting for C-code
151set cindent
152" and here some nice options for cindenting
153set cinoptions={.5s,+.5s,t0,n-2,p2s,(03s,=.5s,>1s,=1s,:1s
154" ----------------------------------------------------------------------}}}
155" TEX special{{{1
156" ----------------------------------------------------------------------
157au BufRead,BufNewFile *.tex,*.html set textwidth=100 "100 caracters max (See gq command)
158au BufRead,BufNewFile *.tex,*.html set formatoptions=cqt "automatic wraping
159au BufRead,BufNewFile *.tex,*.html set wrapmargin=0 "no margin
160au BufRead,BufNewFile *.cls setfiletype tex
161
162" OPTIONAL: Starting with Vim 7, the filetype of empty .tex files defaults to
163" 'plaintex' instead of 'tex', which results in vim-latex not being loaded.
164" The following changes the default filetype back to 'tex':
165let g:tex_flavor='latex'
166" ----------------------------------------------------------------------}}}
167" FORTRAN special{{{1
168" ----------------------------------------------------------------------
169au BufRead,BufNewFile *.src setfiletype fortran
170" ----------------------------------------------------------------------}}}
171" InsertTabWrapper{{{1
172" ----------------------------------------------------------------------
173function! InsertTabWrapper(direction)
174let col = col('.') - 1
175if !col || getline('.')[col - 1] !~ '\k'
176 return "\<tab>"
177elseif "backward" == a:direction
178 return "\<c-p>"
179else
180 return "\<c-n>"
181endif
182endfunction
183
184inoremap <tab> <c-r>=InsertTabWrapper ("forward")<cr>
185inoremap <s-tab> <c-r>=InsertTabWrapper ("backward")<cr>
186
187"source ~/.exrc
188set wildmenu
189
190"Change to directory of current file automatically
191autocmd BufEnter * lcd %:p:h
192" ----------------------------------------------------------------------}}}
193
194" Abbreviations {{{1
195" ----------------------------------------------------------------------
196"func Eatchar(pat)
197" let c = nr2char(getchar())
198" return (c =~ a:pat) ? '' : c
199"endfunc
200"au BufRead,BufNewFile *.html iabbr <silent> H1 <h1></h1><Left><Left><Left><Left><Left><C-R>=Eatchar('\s')<CR>
201"au BufRead,BufNewFile *.html iabbr <silent> H2 <h2></h2><Left><Left><Left><Left><Left><C-R>=Eatchar('\s')<CR>
202"au BufRead,BufNewFile *.html iabbr <silent> H3 <h3></h3><Left><Left><Left><Left><Left><C-R>=Eatchar('\s')<CR>
203"au BufRead,BufNewFile *.html iabbr <silent> CO <code></code><Left><Left><Left><Left><Left><Left><C-R>=Eatchar('\s')<CR>
204"au BufRead,BufNewFile *.html iabbr <silent> PP <p></p><Left><Left><Left><Left><C-R>=Eatchar('\s')<CR>
205"au BufRead,BufNewFile *.m iabbr <silent> p1 disp('');<Left><Left><Left><C-R>=Eatchar('\s')<CR>
206"au BufRead,BufNewFile *.m iab <expr> p0 "disp('-------------- file: ".expand('%')." line: ".line(".")."');"
207"au BufRead,BufNewFile *.c* iabbr <silent> p1 printf("\n");<Left><Left><Left><Left><Left><C-R>=Eatchar('\s')<CR>
208"au BufRead,BufNewFile *.c*,*.h iabbr <silent> ER _error_("");<Left><Left><Left><C-R>=Eatchar('\s')<CR>
209"au BufRead,BufNewFile *.c* ab VV VecView(ug,PETSC_VIEWER_STDOUT_WORLD);
210"au BufRead,BufNewFile *.c* ab AS _assert_();
211"au BufRead,BufNewFile *.c* iab <expr> p0 "printf(\"-------------- file: ".expand('%')." line: %i\\n\",__LINE__);"
212"au BufRead,BufNewFile *.c* iab <expr> pp0 "PetscSynchronizedPrintf(MPI_COMM_WORLD,\"-------------- file: ".expand('%')." line: %i\\n\",__LINE__);\nPetscSynchronizedFlush(MPI_COMM_WORLD);"
213""tex
214"au BufRead,BufNewFile *.tex iab EQ
215" \\begin{equation}
216" \<CR>\end{equation}<up><C-R>=Eatchar('\s')<CR>
217"au BufRead,BufNewFile *.tex iab IT
218" \\begin{itemize}
219" \<CR>\item
220" \<CR>\end{itemize}<up><C-R>=Eatchar('\s')<CR>
221"au BufRead,BufNewFile *.tex iab EN
222" \\begin{enumerate}
223" \<CR>\item
224" \<CR>\end{enumerate}<up><C-R>=Eatchar('\s')<CR>
225"au BufRead,BufNewFile *.tex ab (()) \left( \right)
226"}}}
227" Skeletons {{{1
228au BufNewFile letter.tex 0r ~/.vim/xtr/skeleton/letter.tex
229"}}}
230" Copy and Paste{{{
231"vmap <C-c> y:call system("pbcopy", getreg("\""))<CR>
232"nmap <C-v> :call setreg("\"",system("pbpaste"))<CR>p
233"}}}
Note: See TracBrowser for help on using the repository browser.