-
Notifications
You must be signed in to change notification settings - Fork 0
/
.vimrc
211 lines (180 loc) · 5.42 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
set visualbell
"fg inspiration:
" https://github.com/timbertson/app-customisations/blob/master/vim/vimrc
syntax on
syntax sync minlines=200 " don't lose track when in large syntax blocks
set background=dark
colorscheme solarized
if has("multi_byte")
if &termencoding == ""
let &termencoding = &encoding
endif
set encoding=utf-8
setglobal fileencoding=utf-8
"setglobal bomb
"set fileencodings=ucs-bom,utf-8,latin1
endif
set autoindent
set formatoptions=crqln
set clipboard=unnamed
set preserveindent
set copyindent
" insert a tab at the start of the line, without messing up existing (mixed) indents
nmap <leader><tab> m'0i<tab><esc>`'l
set nojoinspaces " just one space after a period (when joining)
set nocompatible
set nonumber
"set smartcase
set softtabstop=0
set textwidth=0
set tabstop=4 shiftwidth=4
set wrapmargin=0
" reload filetype detection
filetype plugin indent on
filetype off
" run time path
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'VundleVim/Vundle.vim'
Plugin 'Valloric/YouCompleteMe'
Plugin 'vim-syntastic/syntastic'
call vundle#end()
filetype plugin indent on
"execute pathogen#infect()
" do not interfere with syntastic checkers Valloric/YouCompleteMe/commit/bc4e7f
"if clang build fails even after cmake clean i.e. removal of build directory contents
"let g:ycm_register_as_syntastic_checker = 0
"let g:syntastic_cpp_check_header = 1
"let g:syntastic_cpp_auto_refresh_includes = 1
let g:syntastic_c_checkers = ['gcc']
let g:syntastic_cpp_checkers = ['gcc']
let g:syntastic_javascript_closurecompiler_path = '~/google-javascript-closure-compiler/closure-compiler.jar'
let g:syntastic_python_checkers = ['python']
" replace white space on blank lines:
"autocmd BufNewFile,BufRead * exe "g/\\s\\+$/s/\\s\\+$//gc"
" replace tabsize white space by tab:
"autocmd BufNewFile,BufRead * exe "g/[ ]{" . &shiftwidth . "}/s/[ ]{" . &shiftwidth . "}/\\t/gc"
" draw tabs
"autocmd BufNewFile,BufRead * set list listchars=tab:>-
"set list listchars=tab:▸\
"set listchars=tab:>-,trail:_ list
" highlight any spaces that are followed by a tab (the horror!)
" and any _single_ space that comes after ^\t+ (this is usually accedental)
" and also trailing spaces
autocmd BufNewFile,BufRead * match Error /\( \+\t\@=\)\|\(^\(\t\+\)\zs \ze[^ *]\)\|\([^ \t]\zs\s\+$\)\|\(\s\+$\)/
match Error /\( \+\t\@=\)\|\(^\(\t\+\)\zs \ze[^ *]\)\|\([^ \t]\zs\s\+$\)/
" Highlight as Tag or Error if a blank/empty line contains tabs: (spaces only
" are already handled by the above match)
"command! -nargs=0 Spaces set et noet< | retab
fun! Tabsize(sz)
let &l:shiftwidth=a:sz
let &l:tabstop=a:sz
let &l:softtabstop=a:sz
endfun
fun! GlobalTabsize(sz)
let &shiftwidth=a:sz
let &tabstop=a:sz
let &softtabstop=a:sz
endfun
command! -nargs=1 Tabsize call Tabsize(<args>)
set noexpandtab
call GlobalTabsize(4)
" defaults for indent-finder when no other preference is clear from the file
let g:indent_finder_default_style="tab"
let g:indent_finder_default_width="4"
command! -nargs=* SpacesToTab call SpacesToTab()
function! SpacesToTab()
let spaces = ""
let x = 0
while x < &l:shiftwidth
let spaces = spaces . " "
let x = x + 1
endwhile
exe "g/" . spaces . "/%s/" . spaces . "/\\t/gic"
endfunction
command! -nargs=* TabToSpaces call TabToSpaces()
function! TabToSpaces()
let spaces = ""
let x = 0
while x < &l:shiftwidth
let spaces = spaces . " "
let x = x + 1
endwhile
exe "g/\\t/%s/\\t/" . spaces . "/gic"
endfunction
" Set exandtab (insert spaces instead of tabs)
" http://stackoverflow.com/questions/1562336/tab-vs-space-preferences-in-vim#answer-1610732
command! -nargs=* Stab call Stab()
function! Stab()
let l:tabstop = 1 * input('set shiftwidth=')
if l:tabstop > 0
" do we want expandtab as well?
let l:expandtab = confirm('set expandtab?', "&Yes\n&No\n&Cancel")
if l:expandtab == 3
" abort?
return
endif
let &l:sts = l:tabstop
let &l:ts = l:tabstop
let &l:sw = l:tabstop
if l:expandtab == 1
setlocal expandtab
TabToSpaces()
else
setlocal noexpandtab
SpacesToTab()
endif
endif
" show the selected options
try
echohl ModeMsg
echon 'set tabstop='
echohl Question
echon &l:ts
echohl ModeMsg
echon ' shiftwidth='
echohl Question
echon &l:sw
echohl ModeMsg
echon ' sts='
echohl Question
echon &l:sts . ' ' . (&l:et ? ' ' : 'no')
echohl ModeMsg
echon 'expandtab'
finally
echohl None
endtry
endfunction
"already loaded automatically:source $HOME/.vim/plugin/cscope_maps.vim
" any location below plugin is on the runtime path
" Pyclewn GDB interface maps:
" :map <F8> :Cfile /path/to/foobar <Bar> Cbreak main <Bar> Crun <CR>
"
:map <F11> :Cstepi <CR> " step instruction
:map <F10> :Cstep <CR>
:map <F9> :Cnext <CR>
:map <F8> :Ccontinue <CR>
:map <F7> :Cwhere <CR>
:map <F6> :Creverse-next <CR>
:map <F5> :Clist <CR>
:map <F4> :Cprint $sp<CR>
" stack pointer
:map <F3> :Cprint $pc<CR>
" Needed for tmux and vim to play nice
map <Esc>[A <Up>
map <Esc>[B <Down>
map <Esc>[C <Right>
map <Esc>[D <Left>
" Console movement
cmap <Esc>[A <Up>
cmap <Esc>[B <Down>
cmap <Esc>[C <Right>
cmap <Esc>[D <Left>
" https://superuser.com/questions/401926/how-to-get-shiftarrows-and-ctrlarrows-working-in-vim-in-tmux
if &term =~ '^screen'
" tmux will send xterm-style keys when its xterm-keys option is on
execute "set <xUp>=\e[1;*A"
execute "set <xDown>=\e[1;*B"
execute "set <xRight>=\e[1;*C"
execute "set <xLeft>=\e[1;*D"
endif