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.
|
---|
6 | set nocompatible
|
---|
7 | " UNIX special
|
---|
8 | set shell=/bin/bash
|
---|
9 | " jingle bells, jingle bells, hingle bells, ....
|
---|
10 | set errorbells
|
---|
11 | " keep 100 lines of command line history
|
---|
12 | set history=100
|
---|
13 | " show the cursor position all the time
|
---|
14 | set ruler
|
---|
15 | " display incomplete commands
|
---|
16 | set showcmd
|
---|
17 | " display curent mode
|
---|
18 | set showmode
|
---|
19 | "----------------------------------------------------------------------}}}
|
---|
20 | " Text-Formatting, Identing, Tabbing{{{1
|
---|
21 | " ----------------------------------------------------------------------
|
---|
22 | " allow backspacing (to delete) over everything in insert mode
|
---|
23 | set backspace=indent,eol,start
|
---|
24 | " number of spaces the tab stands for
|
---|
25 | set tabstop=3
|
---|
26 | " number of spaces the softtab (>>) stands for
|
---|
27 | set softtabstop=3
|
---|
28 | " number of spaces used for (auto)indenting
|
---|
29 | set shiftwidth=3
|
---|
30 | " a <tab> in an indent inserts 'shiftwidth' spaces (not tabstop)
|
---|
31 | set smarttab
|
---|
32 | " always set autoindenting on
|
---|
33 | set autoindent
|
---|
34 | "smartindenting useful (use '=')
|
---|
35 | set smartindent
|
---|
36 |
|
---|
37 | "base folds on markers
|
---|
38 | set foldmethod=marker
|
---|
39 | set foldtext=IssmFoldText()
|
---|
40 | " -----------------------------------------------------------}}}
|
---|
41 | " Backups {{{1
|
---|
42 | " -----------------------------------------------------------
|
---|
43 | " updatecount number of characters typed to cause a swap file update (0->disable)
|
---|
44 | set uc=0
|
---|
45 | " make no backups
|
---|
46 | set 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 \.)
|
---|
55 | set magic
|
---|
56 | " begin search at top when EOF reached
|
---|
57 | set wrapscan
|
---|
58 | " jump to matches during entering the pattern
|
---|
59 | set sm
|
---|
60 | " do incremental searching
|
---|
61 | set incsearch
|
---|
62 | "highlight all matches
|
---|
63 | set hlsearch
|
---|
64 | " Do not toggle 'g' and 'c' with :s///gc
|
---|
65 | set noedcompatible
|
---|
66 |
|
---|
67 | " use 'g'-flag when substituting (subst. all matches in that line, not only
|
---|
68 | " first) to turn off, use g
|
---|
69 | set gdefault
|
---|
70 | " how command line completion works (use tab to complete the file name)
|
---|
71 | set wildmode=list:longest,list:full
|
---|
72 | " ignore some files for filename completion
|
---|
73 | set wildignore=*.o,*.r,*.so,*.sl,*.tar,*.tgz
|
---|
74 | " some filetypes got lower priority
|
---|
75 | set su=.h,.bak,~,.o,.info,.swp,.obj
|
---|
76 | " ----------------------------------------------------------------------}}}
|
---|
77 | " Colors and theme {{{1
|
---|
78 | " ----------------------------------------------------------------------
|
---|
79 | " use 256 colors
|
---|
80 | "set t_Co=8
|
---|
81 | set t_Co=256
|
---|
82 | " backgrounb color
|
---|
83 | "set background=light
|
---|
84 | "set background=dark
|
---|
85 | " colorscheme
|
---|
86 | "colorscheme issm_white
|
---|
87 | colorscheme issm_black
|
---|
88 | " ----------------------------------------------------------------------}}}
|
---|
89 |
|
---|
90 | " Mappings{{{1
|
---|
91 | " ----------------------------------------------------------------------
|
---|
92 | "stop highlightings when spce is pressed
|
---|
93 | nnoremap <silent> <Space> :silent noh<Bar>echo<CR>
|
---|
94 |
|
---|
95 | "line numbering in flip-flop
|
---|
96 | map num :set number!<CR>
|
---|
97 |
|
---|
98 | " save & "make" the current file in all modes
|
---|
99 | map <F8> :w <Enter> :make <Enter><Enter>
|
---|
100 | map! <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
|
---|
107 | map Q gq
|
---|
108 | " ----------------------------------------------------------------------}}}
|
---|
109 | " Autocommands {{{1
|
---|
110 | " ----------------------------------------------------------------------
|
---|
111 | " Only do this part when compiled with support for autocommands.
|
---|
112 | if 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 |
|
---|
136 | endif " has("autocmd")
|
---|
137 | " ----------------------------------------------------------------------}}}
|
---|
138 | " Matlab special {{{1
|
---|
139 | " ----------------------------------------------------------------------
|
---|
140 | "" associate *.par with matlab filetype
|
---|
141 | au BufRead,BufNewFile *.par setfiletype matlab
|
---|
142 | au BufRead,BufNewFile *.tpl setfiletype html
|
---|
143 | " ----------------------------------------------------------------------}}}
|
---|
144 | " C special{{{1
|
---|
145 | " ----------------------------------------------------------------------
|
---|
146 | "indenting for C-code
|
---|
147 | set cindent
|
---|
148 | " and here some nice options for cindenting
|
---|
149 | set cinoptions={.5s,+.5s,t0,n-2,p2s,(03s,=.5s,>1s,=1s,:1s
|
---|
150 | " ----------------------------------------------------------------------}}}
|
---|
151 | " TEX special{{{1
|
---|
152 | " ----------------------------------------------------------------------
|
---|
153 | au BufRead,BufNewFile *.tex,*.html set textwidth=100 "100 caracters max (See gq command)
|
---|
154 | au BufRead,BufNewFile *.tex,*.html set formatoptions=cqt "automatic wraping
|
---|
155 | au BufRead,BufNewFile *.tex,*.html set wrapmargin=0 "no margin
|
---|
156 | au 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':
|
---|
161 | let g:tex_flavor='latex'
|
---|
162 | " ----------------------------------------------------------------------}}}
|
---|
163 | " FORTRAN special{{{1
|
---|
164 | " ----------------------------------------------------------------------
|
---|
165 | au BufRead,BufNewFile *.src setfiletype fortran
|
---|
166 | " ----------------------------------------------------------------------}}}
|
---|
167 | " InsertTabWrapper{{{1
|
---|
168 | " ----------------------------------------------------------------------
|
---|
169 | function! InsertTabWrapper(direction)
|
---|
170 | let col = col('.') - 1
|
---|
171 | if !col || getline('.')[col - 1] !~ '\k'
|
---|
172 | return "\<tab>"
|
---|
173 | elseif "backward" == a:direction
|
---|
174 | return "\<c-p>"
|
---|
175 | else
|
---|
176 | return "\<c-n>"
|
---|
177 | endif
|
---|
178 | endfunction
|
---|
179 |
|
---|
180 | inoremap <tab> <c-r>=InsertTabWrapper ("forward")<cr>
|
---|
181 | inoremap <s-tab> <c-r>=InsertTabWrapper ("backward")<cr>
|
---|
182 |
|
---|
183 | "source ~/.exrc
|
---|
184 | set wildmenu
|
---|
185 |
|
---|
186 | "Change to directory of current file automatically
|
---|
187 | autocmd BufEnter * lcd %:p:h
|
---|
188 | " ----------------------------------------------------------------------}}}
|
---|
189 |
|
---|
190 | " Abbreviations {{{1
|
---|
191 | " ----------------------------------------------------------------------
|
---|
192 | func Eatchar(pat)
|
---|
193 | let c = nr2char(getchar())
|
---|
194 | return (c =~ a:pat) ? '' : c
|
---|
195 | endfunc
|
---|
196 | au BufRead,BufNewFile *.html iabbr <silent> H1 <h1></h1><Left><Left><Left><Left><Left><C-R>=Eatchar('\s')<CR>
|
---|
197 | au BufRead,BufNewFile *.html iabbr <silent> H2 <h2></h2><Left><Left><Left><Left><Left><C-R>=Eatchar('\s')<CR>
|
---|
198 | au BufRead,BufNewFile *.html iabbr <silent> H3 <h3></h3><Left><Left><Left><Left><Left><C-R>=Eatchar('\s')<CR>
|
---|
199 | au BufRead,BufNewFile *.html iabbr <silent> CO <code></code><Left><Left><Left><Left><Left><Left><C-R>=Eatchar('\s')<CR>
|
---|
200 | au BufRead,BufNewFile *.html iabbr <silent> PP <p></p><Left><Left><Left><Left><C-R>=Eatchar('\s')<CR>
|
---|
201 | au BufRead,BufNewFile *.m iabbr <silent> p1 disp('');<Left><Left><Left><C-R>=Eatchar('\s')<CR>
|
---|
202 | au BufRead,BufNewFile *.m iab <expr> p0 "disp('-------------- file: ".expand('%')." line: ".line(".")."');"
|
---|
203 | au BufRead,BufNewFile *.c* iabbr <silent> p1 printf("\n");<Left><Left><Left><Left><Left><C-R>=Eatchar('\s')<CR>
|
---|
204 | au BufRead,BufNewFile *.c*,*.h iabbr <silent> ER _error_("");<Left><Left><Left><C-R>=Eatchar('\s')<CR>
|
---|
205 | au BufRead,BufNewFile *.py iabbr <silent> ER raise NameError('')<Left><Left><C-R>=Eatchar('\s')<CR>
|
---|
206 | au BufRead,BufNewFile *.m iabbr <silent> ER error('');<Left><Left><Left><C-R>=Eatchar('\s')<CR>
|
---|
207 | au BufRead,BufNewFile *.c* ab VV VecView(ug,PETSC_VIEWER_STDOUT_WORLD);
|
---|
208 | au BufRead,BufNewFile *.c* ab AS _assert_();
|
---|
209 | au BufRead,BufNewFile *.c* iab <expr> p0 "printf(\"-------------- file: ".expand('%')." line: %i\\n\",__LINE__);"
|
---|
210 | au BufRead,BufNewFile *.c* iab <expr> pp0 "PetscSynchronizedPrintf(MPI_COMM_WORLD,\"-------------- file: ".expand('%')." line: %i\\n\",__LINE__);\nPetscSynchronizedFlush(MPI_COMM_WORLD);"
|
---|
211 | "tex
|
---|
212 | au BufRead,BufNewFile *.tex iab EQ
|
---|
213 | \\begin{equation}
|
---|
214 | \<CR>\end{equation}<up><C-R>=Eatchar('\s')<CR>
|
---|
215 | au BufRead,BufNewFile *.tex iab IT
|
---|
216 | \\begin{itemize}
|
---|
217 | \<CR>\item
|
---|
218 | \<CR>\end{itemize}<up><C-R>=Eatchar('\s')<CR>
|
---|
219 | au BufRead,BufNewFile *.tex iab EN
|
---|
220 | \\begin{enumerate}
|
---|
221 | \<CR>\item
|
---|
222 | \<CR>\end{enumerate}<up><C-R>=Eatchar('\s')<CR>
|
---|
223 | au BufRead,BufNewFile *.tex ab (()) \left( \right)
|
---|
224 | "}}}
|
---|
225 | " Skeletons {{{1
|
---|
226 | au BufNewFile letter.tex 0r ~/.vim/xtr/skeleton/letter.tex
|
---|
227 | "}}}
|
---|