-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathvimrc
More file actions
246 lines (204 loc) · 4.96 KB
/
Copy pathvimrc
File metadata and controls
246 lines (204 loc) · 4.96 KB
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
" Use filetypes
filetype plugin indent on
" Display {{{
syn on
set number
set scrolloff=3
set showcmd
set t_Co=256
" }}}
" WildMenu {{{
set wildmode=list:longest
set wildmenu
set wildignore+=*.o,*.obj,*.exe,*.dll
set wildignore+=*.py[co]
set wildignore+=*.swp
set wildignore+=*.bbl,*.aux,*.blg,*.fls,*.pdf,*.fdb_latexmk,*.bbl,*.gz,*.out,*.toc
" }}}
" GUI
set guioptions=aegiL
set guifont=Noto\ Sans\ Mono\ 10
" Status line
set laststatus=2
" Formatting {{{
set backspace=eol,start,indent
set wrap
set lbr
set formatoptions+=w
set shiftwidth=4
set tabstop=4
set copyindent
" }}}
" Behaviour {{{
set autochdir
set autoread
set ignorecase
set smartcase
set gdefault
set incsearch
set nohlsearch
set hidden
set switchbuf=usetab,newtab
" set spell
set foldopen-=block
" Remember position in file
augroup line_return
au!
au BufReadPost *
\ if line("'\"") > 0 && line("'\"") <= line("$") |
\ execute 'normal! g`"zvzz' |
\ endif
augroup END
" }}}
" Plugins {{{
" Powerline is special
" set rtp+=~/.vim/bundle/powerline/powerline/bindings/vim
" Some settings for LaTeX-suite
set shellslash
" Don't let vim-space wreck select-mode
let g:space_disable_select_mode = 1
" Or cabbreviations
let g:space_no_quickfix = 1
" Colors
let g:solarized_termcolors=16
set bg=dark
colo BusyBee
if filereadable(expand("~/.vimrc.bundles"))
source ~/.vimrc.bundles
endif
" Pymode
let g:pymode_lint_ignore = "E501"
let g:pymode_options = 0
let g:pymode_lint_cwindow = 0
let g:pymode_rope_lookup_project = 0
let g:pymode_rope_complete_on_dot = 0
"let g:pymode_indent = 0
let g:snipMate = { 'snippet_version' : 1 }
" }}}
" Mappings {{{
" Navigation
noremap <silent> k gk
noremap <silent> j gj
noremap <silent> ^ g^
noremap <silent> $ g$
inoremap <silent> <Up> <C-o>gk
inoremap <silent> <Down> <C-o>gj
inoremap <silent> <Home> <C-o>g^
inoremap <silent> <End> <C-o>g$
" Laze
nnoremap ; :
" Sane yank
nnoremap Y y$
nnoremap L gt
nnoremap H gT
nmap ]q :cn<cr>zv
nmap [q :cp<cr>zv
imap <C-p> <Esc>gwapgi
" Toggleable options
nmap <F9> :set invhlsearch<cr>
nmap <F10> :set invpaste<cr>
" Annoying keys
nmap K <nop>
" Fix broken highlighting
noremap <F12> :syntax sync fromstart<cr>
map <F11> :echo "hi<" . synIDattr(synID(line("."),col("."),1),"name") . '> trans<'
\ . synIDattr(synID(line("."),col("."),0),"name") . "> lo<"
\ . synIDattr(synIDtrans(synID(line("."),col("."),1)),"name") . ">"<CR>
" Window navigation
noremap <C-h> <C-w>h
noremap <C-j> <C-w>j
noremap <C-k> <C-w>k
noremap <C-l> <C-w>l
nnoremap <C-c> <C-w>c
nnoremap _ <C-w>-
nnoremap + <C-w>+
nmap <cr> za
map <c-n> :NERDTreeToggle<cr>
" }}}
" Commands {{{
function! OpenInNewTab()
tabnew
browse e
endfunction
command! Tbe call OpenInNewTab()
" }}}
" Prevent the cursor moving when clicking the window to focus it.
augroup NO_CURSOR_MOVE_ON_FOCUS
au!
au FocusLost * let g:oldmouse=&mouse | set mouse=
au FocusGained * if exists('g:oldmouse') | let &mouse=g:oldmouse | unlet g:oldmouse | endif
augroup END
" Auto-reload .vimrc when saved
augroup Reload-Vimrc
au!
autocmd BufWritePost $MYVIMRC source % | doautocmd ColorScheme .vimrc
augroup END
" Command to process file whenever it's changed
function! CompileFunction(cmd)
let b:compile_cmd = a:cmd
augroup MyCompile
au!
au BufWritePost <buffer> execute 'silent !' . b:compile_cmd . ' ' . expand('%:p')
augroup END
" execute '!' . a:cmd . expand('%:p')
" execute '!' . a:cmd . ' ' . expand('%:p')
endfunction
command! -nargs=1 Compile call CompileFunction('<args>')
function! MovePastBlank(motion)
execute 'normal! '.a:motion
let prev_pos = getpos('.')
while expand('<cword>') == ''
execute 'normal! '.a:motion
let current_pos = getpos('.')
if current_pos == prev_pos
return
else
let prev_pos = current_pos
endif
endwhile
endfunction
" Handle existence of swap files semi-sanely {{{
function! s:HandleRecover()
echo system('diff - ' . shellescape(expand('%:p')), join(getline(1, '$'), "\n") . "\n")
if v:shell_error
call s:DiffOrig()
else
echohl WarningMsg
echomsg "No differences; deleting the old swap file."
echohl NONE
call delete(b:swapname)
endif
endfunction
function! s:DiffOrig()
vert new
set bt=nofile
r #
0d_
diffthis
wincmd p
diffthis
endfunction
augroup HandleRecover
au!
autocmd SwapExists * let b:swapchoice = '?' | let b:swapname = v:swapname
autocmd BufReadPost * let b:swapchoice_likely = (&l:ro ? 'o' : 'r')
autocmd BufEnter * let b:swapchoice_likely = (&l:ro ? 'o' : 'e')
autocmd BufWinEnter * if exists('b:swapchoice') && exists('b:swapchoice_likely') | let b:swapchoice = b:swapchoice_likely | unlet b:swapchoice_likely | endif
autocmd BufWinEnter * if exists('b:swapchoice') && b:swapchoice == 'r' | call s:HandleRecover() | endif
augroup END
" }}}
" Filetypes {{{
" Vim {{{
augroup ft_vim
au!
au FileType vim setlocal foldmethod=marker
augroup END
" }}}
" LaTeX
let g:tex_flavor = "latex"
" }}}
" Local changes {{{
if filereadable(expand("~/.vimrc.local"))
source ~/.vimrc.local
endif
" }}}