-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathvimrc
305 lines (235 loc) · 8.06 KB
/
vimrc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
" public setup
" ============
syntax enable
" clear highlighting
highlight clear
set t_Co=256 " enable 256 colors
" limits
set history=500
" map leader key to comma (,)
let mapleader=","
" line numbers
set number
set relativenumber
" tab settings
set expandtab
set shiftwidth=2
set softtabstop=2
" indenting
set cindent
set autoindent
set smartindent
set backspace=indent,eol,start
" folding
set nofoldenable
" set clipboard to x-windows selection
set clipboard=unnamed
" set fileformat to unix
set fileformat=unix
" turn on incremental search with ignore case (except explicit caps) and
" highlighting
set hlsearch
set incsearch
set ignorecase
set smartcase
" disable backup files
set nobackup
" show list instead of just completing
set wildmenu
set wildmode=longest,list
" complete options
set completeopt=menuone,menu,longest,preview
" set tag locations
set tags=tags;/
set tags+=~/.vim/tags/stl_tags
" copy up to 1000 lines from one file to another
set viminfo='1000,\"2000,s2000,h
" Set spell language
set spelllang=de_ch
" wildignore
set wildignore+=*.o,*.lo,*.la,*.obj,.git,*.pyc,*.so,*/.git/*
" Don't show currect mode
set noshowmode
" set number formats for Ctrl+A and Ctrl+X
set nrformats=alpha,octal,hex
" undo files
if version >= 703
set undodir=~/.vim/undodir
set undofile
endif
" ----------------------
" ---- Highlighting ----
" ----------------------
" diff highlighting
highlight DiffAdd cterm=none ctermfg=64 ctermbg=235 gui=none guifg=Black guibg=Green
highlight DiffDelete cterm=none ctermfg=124 ctermbg=235 gui=none guifg=Black guibg=Red
highlight DiffChange cterm=none ctermfg=136 ctermbg=235 gui=none guifg=Black guibg=Yellow
highlight DiffText cterm=none ctermfg=33 ctermbg=235 gui=none guifg=Black guibg=Magenta
" status line highlighting
"highlight! User1 cterm=bold ctermfg=LightGrey ctermbg=52 guifg=Black guibg=#665555
"highlight! User2 cterm=bold ctermfg=DarkGreen ctermbg=52 guifg=Green guibg=#443333
"highlight! User3 cterm=bold ctermfg=DarkCyan ctermbg=52 guifg=Cyan guibg=#443333
"highlight! User4 cterm=bold ctermfg=DarkCyan ctermbg=52 guifg=Cyan guibg=#443333
" cursor line highlighting
:hi CursorLine cterm=NONE ctermbg=darkred ctermfg=white guibg=darkred guifg=white
:hi CursorColumn cterm=NONE ctermbg=darkred ctermfg=white guibg=darkred guifg=white
":nnoremap <Leader>c :set cursorline! cursorcolumn!<CR>
set cursorline! cursorcolumn!
" ----------------------
" ---- Status line ----
" ----------------------
" status line settings
set laststatus=2 " Always show the statusline
"set statusline=%4*---%1*\ %F%m%r%h%w\ %2*%{fugitive#statusline()}%1*\ %{&ff}\ %Y\ \[0x\%02.2B=\%03.3b]\ [%l,%v\ %p%%\ %Lb]\ %3*\[%F\]%1*
"set statusline= " clear the statusline for when vimrc is reloaded
"set statusline=%t "tail of the filename
"set statusline+=[%{strlen(&fenc)?&fenc:'none'}, "file encoding
"set statusline+=%{&ff}] "file format
"set statusline+=%h "help file flag
"set statusline+=%m "modified flag
"set statusline+=%r "read only flag
"set statusline+=%y "filetype
"set statusline+=%= "left/right separator
"set statusline+=%c, "cursor column
"set statusline+=%l/%L "cursor line/total lines
"set statusline+=\ %P "percent through file
" ----------------------
" ---- Autocommands ----
" ----------------------
"
if has("autocmd")
" set filetypes
autocmd BufNewFile,BufRead *.gv set filetype=dot
autocmd BufNewFile,BufRead *.feature set filetype=cucumber
" open files at the last opened position
autocmd BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
" automatically open and close the popup menu / preview window
autocmd CursorMovedI,InsertLeave * if pumvisible() == 0 | silent! pclose | endif
" remove trailing whitespace on write
autocmd BufWritePre * :%s/\s\+$//e
" source the vimrc file after saving it
autocmd BufWritePost .\=vimrc source $MYVIMRC
" Delete .netrwhist ( netrw history file ) after leaving vim
autocmd VimLeave * if filereadable(".netrwhist") | call delete(".netrwhist") | endif
" load html5 highlighting
"autocmd FileType html source ~/.vim/html5-syntax.vim
autocmd BufNewFile,BufRead *.html source ~/.vim/config/programming-html/html5-syntax.vimrc
" --------
" mappings
" --------
" if FileType is c or cpp then execute make
autocmd FileType c,cpp,cucumber,tex map <F5> :w<CR>:make<CR>
autocmd FileType c,cpp,cucumber,tex imap <F5> <ESC>:w<CR>:make<CR>
" if FileType is python then start python
autocmd FileType python map <F5> :w<CR>:!python "%"<CR>
autocmd FileType python imap <F5> <ESC>:w<CR>:!python "%"<CR>
" if FileType is shell script then start shell script
autocmd FileType sh map <F5> :w<CR>:!$SHELL "%"<CR>
autocmd FileType sh imap <F5> <ESC>:w<CR>:!$SHELL "%"<CR>
endif
" ------------------
" ---- Mappings ----
" ------------------
" change window
nnoremap <leader>1 1
nnoremap <leader>2 2
nnoremap <leader>3 3
nnoremap <leader>4 4
" switch background mode
nnoremap <leader>l :set background=light<CR>
" clear search pattern
map <S-F2> :nohlsearch<CR>
imap <S-F2> <ESC>:nohlsearch<CR>
" smart search
" places searched word in middle of the screen if
" not already visible
nnoremap <silent> n n:call <SID>MaybeMiddle()<CR>
nnoremap <silent> N N:call <SID>MaybeMiddle()<CR>
function s:MaybeMiddle()
if winline() == 1 || winline() == winheight(0)
normal! zz
endif
endfunction
" toggle numbering
map <F8> :set number! relativenumber!<CR>
imap <F8> :set number! relativenumber!<CR>
" Note: F5 is already mapped in autocmd section
"" Shebang
"map <S-F6> :call SetExecutable()<CR>
"imap <S-F6> <ESC>:call SetExecutable()<CR>
"" Doxygen
"map <F7> :Dox<CR>
"imap <F7> <ESC>:Dox<CR>
" Note: Shift + F7 is already mapped in autocmd section
" Spelling
map <F9> :set spell!<CR>
imap <F9> <ESC>:set spell!<CR>
"" extradite.vim
"map <S-F9> :Extradite<CR>
"imap <S-F9> <ESC>:Extradite<CR>
" Next error to F10
map <F10> :cn<CR>
imap <F10> <ESC>:cn<CR>
"
" shortcut to auto indent entire file
map <F11> 1G=G''
imap <F11> <ESC>1G=Ga''
" shortcut to replace word under cursor
nnoremap <leader>* :%s/<c-r><c-w>/<c-r><c-w>/gc<Left><Left><Left>
vnoremap <leader>* :s/<c-r><c-w>/<c-r><c-w>/gc<Left><Left><Left>
" shortcut to Ggrep word under curser or selected text in visual mode
nnoremap <leader>g :Ggrep '\b<C-R><C-W>\b'<CR>:cw<CR>
vmap <leader>g y:Ggrep '<C-R>"'<CR>:cw<CR>
"" Conque shell horizontal split -> start ipython
"map <S-F11> :ConqueTermSplit ipython<CR>
"imap <S-F11> <ESC>:ConqueTermSplit ipython<CR>
"" Conque Shell horizontal split -> start bash
"map <S-F12> :ConqueTermSplit bash<CR>
"imap <S-F12> <ESC>:ConqueTermSplit bash<CR>
" toggle paste mode
map <S-F3> :set paste!<CR>
" switch buffer mappings
map <a-left> :bp<CR>
imap <a-left> <ESC>:bp<CR>
map <a-right> :bn<CR>
imap <a-right> <ESC>:bn<CR>
map <C-j> :bp<CR>
imap <C-j> <ESC>:bp<CR>
map <C-k> :bn<CR>
imap <C-k> <ESC>:bn<CR>
" scrolling
"nnoremap <C-S-J> j<C-e>
"nnoremap <C-S-K> k<C-y>
" selection
"noremap <S-End> v$
"noremap <S-Home> v^
" open vimrc from any location
"nmap <leader>v :tabedit $MYVIMRC<CR>
nmap <leader>v :e $MYVIMRC<CR>
" tab navigation
"inoremap <C-h> :tabprevious<CR>
"inoremap <C-h> <ESC>:tabprevious<CR>
map <C-l> :tabnext<CR>
imap <C-l> <ESC>:tabnext<CR>
" remap code completion to Ctrl+Space
inoremap <Nul> <C-x><C-o>
"inoremap <C-@> <C-R>=SuperCleverTab()<CR>
" smart home function
function! SmartHome()
let s:col = col(".")
normal! ^
if s:col == col(".")
normal! 0
endif
endfunction
nnoremap <silent> <Home> :call SmartHome()<CR>
inoremap <silent> <Home> <C-O>:call SmartHome()<CR>
" map highlighting group under cursor
map <C-S-H> :call <SID>SynStack()<CR>
" DON'T EDIT BELOW
" load config modules
runtime! config/**/*.vimrc
" load all plugins
packloadall
" generate all helptag documentation
silent! helptags ALL