forked from iancmcc/home-directory
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.vimrc
230 lines (195 loc) · 4.74 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
set nocompatible
set enc=utf-8
filetype on
filetype plugin on
filetype indent on
let python_highlight_all = 1
syntax on
set autowrite
set incsearch
set hlsearch
set showmode
set ignorecase
set showmatch
set matchtime=2
set noerrorbells
set ru
set ts=4
set et
set number
set wmh=0
set sw=4
set tw=79
set bs=2
set smarttab
"set autoindent
"set smartindent
"autocmd BufRead *.py set smartindent cinwords=if,elif,else,for,while,try,except,finally,def,class
set matchpairs=(:),[:],{:},<:>
inoremap # X#
set pastetoggle=<F3>
set viminfo='1000,f1,<500,:500,/500
autocmd Syntax javascript match Error /,\_s*[)}\]]/
map <C-J> <C-W>j
map <C-K> <C-W>k
map <c-h> <c-w>h
map <c-l> <c-w>l
map - <C-W>-
map + <C-W>+
map <M-<> <C-W><
map <M->> <C-W>>
set wmw=0
set wmh=0
set wildignore=*.pyc,*.jpg,*.png,*.gif,*.gz
function! CHANGE_CURR_DIR()
let _dir = expand("%:p:h")
exec "cd " . _dir
unlet _dir
endfunction
autocmd BufEnter * call CHANGE_CURR_DIR()
autocmd BufWritePre *.py normal m`:%s/\s\+$//e ``
if &term == "xterm-color"
set t_kb=
fixdel
endif
"nnoremap <silent> Q :Ex<CR>
noremap Y y$
nmap <Tab> >>
nmap <S-Tab> <<
vmap <Tab> >gv
vmap <S-Tab> <gv
nmap ,pdb Oimport pdb; pdb.set_trace()<Esc>
set whichwrap=h,l,[,],~
set backspace=eol,start,indent
inoremap ( ()<Left>
inoremap [ []<Left>
inoremap { {}<Left>
autocmd Syntax html,vim inoremap < <lt>><ESC>i| inoremap > <c-r>=ClosePair('>')<CR>
inoremap ) <c-r>=ClosePair(')')<CR>
inoremap ] <c-r>=ClosePair(']')<CR>
inoremap } <c-r>=ClosePair('}')<CR>
inoremap """ <c-r>=QuoteDelim('"""')<CR>
inoremap " <c-r>=QuoteDelim('"')<CR>
inoremap ' <c-r>=QuoteDelim("'")<CR>
inoremap <D-CR> <Esc>o
autocmd Syntax python inoremap <S-CR> <Esc>A:<Esc>o
autocmd Syntax css,javascript,html inoremap <S-CR> <Esc>A;<Esc>o
vnoremap ( `>a)`<i(
vnoremap ) `>a)`<i(
vnoremap { `>a}`<i{
vnoremap } `>a}`<i{
vnoremap " `>a"`<i"
vnoremap ' `>a'`<i'
vnoremap ` `>a``<i`
vnoremap [ `>a]`<i[
vnoremap ] `>a]`<i[
function! ClosePair(char)
if getline('.')[col('.') - 1] == a:char
return "\<Right>"
else
return a:char
endif
endf
function! QuoteDelim(char)
let slen = len(a:char)
let line = getline('.')
let col = col('.') - slen + 1
if line[col - 2] == "\\"
"Inserting a quoted quotation mark into the string
return a:char
elseif line[col - 1] == a:char
"Escaping out of the string
return "\<Right>"
else
"Starting a string
let alist = []
for n in range(slen)
call add(alist,"\<Left>")
endfor
return a:char.a:char.join(alist,"")
endif
endf
function! InAnEmptyPair()
let cur = strpart(getline('.'),getpos('.')[2]-2,2)
for pair in (split(&matchpairs,',') + ['":"',"':'"])
if cur == join(split(pair,':'),'')
return 1
endif
endfor
return 0
endfunc
func! DeleteEmptyPairs()
if InAnEmptyPair()
return "\<Left>\<Del>\<Del>"
else
return "\<BS>"
endif
endfunc
inoremap <expr> <BS> DeleteEmptyPairs()
func! MultiLinePairs()
if InAnEmptyPair()
return "\<CR>\<Esc>O"
else
return "\<CR>"
endif
endfunc
inoremap <expr> <CR> MultiLinePairs()
function! PythonCommentSelection() range
let commentString = "#"
let cl = a:firstline
let ind = 1000
while (cl <= a:lastline)
if strlen(getline(cl))
let cind = indent(cl)
let ind = ((ind < cind) ? ind : cind)
endif
let cl = cl + 1
endwhile
if (ind == 1000)
let ind = 1
else
let ind = ind + 1
endif
let cl = a:firstline
execute ":".cl
while (cl <= a:lastline)
if strlen(getline(cl))
execute "normal ".ind."|i".commentString
endif
execute "normal \<Down>"
let cl = cl + 1
endwhile
execute "normal \<Up>"
endfunction
function! PythonUncommentSelection() range
let commentString = "#"
let cl = a:firstline
while (cl <= a:lastline)
let ul = substitute(getline(cl),
\"\\(\\s*\\)".commentString."\\(.*\\)$", "\\1\\2", "")
call setline(cl, ul)
let cl = cl + 1
endwhile
endfunction
function! TogglePythonComment() range
let cl = a:firstline
let fc = substitute(getline(cl), "^\\s*\\(.\\).*", "\\1", "")
if (fc == "#")
execute ":".a:firstline.",".a:lastline."call PythonUncommentSelection()"
else
execute ":".a:firstline.",".a:lastline."call PythonCommentSelection()"
endif
endfunction
map <D-/> :call TogglePythonComment()<CR>
" TAGS "
autocmd FileType python set tags=/Users/$USER/.tags/python/tags
autocmd FileType javascript set tags=/Users/$USER/.tags/js/tags
cs add $CSCOPE_DB
" Other stuff "
autocmd FileType python set omnifunc=pythoncomplete#Complete
map T :TlistToggle<CR>
map Q :NERDTreeToggle $ZENHOME/Products<CR>
nmap NF :NERDTreeFind<CR>
let g:NERDTreeWinPos = 'right'
set laststatus=2
set statusline=%{GitBranch()}