forked from satiani/init
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.vimrc
145 lines (127 loc) · 3.98 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
" Vim Options
set wildmenu
set hidden
set t_Co=256
set completeopt=longest,menuone
set directory=/home/satiani/vimswap/
set diffexpr="sdiff --strip-trailing-cr"
set diffopt=vertical,filler
set incsearch
set showmatch " Show matching brackets.
set sw=4
set et
set expandtab
set sts=4
set viminfo='20,\"50
set suffixes=.bak,~,.swp,.o,.info,.aux,.log,.dvi,.bbl,.blg,.brf,.cb,.ind,.idx,.ilg,.inx,.out,.toc
set ruler
set printoptions=paper:letter
set history=50
set fileencodings=ucs-bom,utf-8,latin1
set backspace=indent,eol,start
set autoindent
set cpo&vim
set modeline
set tags=tags;/
set laststatus=2
set statusline=%<%f\ %h%m%r%=%-14.(%l,%c%V%)\ %P
filetype plugin on
" Key mappings
inoremap <silent><A-Left> <Esc>:tabprevious<CR>
inoremap <silent><A-Right> <Esc>:tabnext<CR>
inoremap
map <Leader>\ :n<CR>
map <Leader>- :prev<CR>
map <c-w>F <c-w>_<c-w><bar>
map <c-w>O <c-w>w<c-w>_<c-w><bar>
map <silent><A-Down> :tabnew<CR>
map <silent><A-Left> :tabprevious<CR>
map <silent><A-Right> :tabnext<CR>
map <silent><A-Up> :tabnew .<CR>
map <silent><F3> :TlistToggle<CR>
map <F8> :!/usr/bin/ctags -R --c++-kinds=+p --fields=+iaS --extra=+q .<CR>
map <silent> <F2> :call BufferList()<CR>
map <silent> [12~ :call BufferList()<CR>
map <silent> OS :call ChangeCurrDir()<CR>
map <silent> O1;2S :call ChangeCurrDir()<CR>:e .<CR>
map <silent> :call ToggleOverLengthMatch()<CR>
" Utility functions
function! ChangeCurrDir()
if !exists("b:eclim_temp_window")
let _dir = expand("%:p:h")
exec join(["cd", escape(_dir, " ")])
echo "Changed current directory to " . _dir
unlet _dir
endif
endfunction
function! ToggleOverLengthMatch()
if !exists("b:overlength_match_flag")
"TODO: find a way to use a variable in the pattern used in the match
"command. Without this, we'll have to use hardcoded overlength
"thresholds. Using 'execute' trick doesn't work for some reason.
match OverLength /\%81v.*/
let b:overlength_match_flag = 1
let b:previous_text_width = &tw
setlocal tw=80
echo "Changed textwidth to 80"
else
match none
unlet b:overlength_match_flag
"setlocal takes only number literals, to use variables
"one must construct the command dynamically
execute 'setlocal tw=' . b:previous_text_width
echo "Reset textwidth to " . b:previous_text_width
unlet b:previous_text_width
endif
endfunction
function! SetPhpStyle()
set sw=2
set sts=2
endfunction
" General Settings
au FileType php call SetPhpStyle()
syntax on
colorscheme desert256
highlight OverLength ctermbg=red ctermfg=white guibg=#592929
let Tlist_WinWidth = 50
" Python extensions
python << EOF
import vim
def SetBreakpoint():
import re
nLine = int( vim.eval('line(".")'))
strLine = vim.current.line
strWhite = re.search('^(\s*)', strLine).group(1)
vim.current.buffer.append(
"%(space)spdb.set_trace() %(mark)s Breakpoint %(mark)s" %
{'space':strWhite, 'mark': '#'*30}, nLine - 1)
for strLine in vim.current.buffer:
if strLine == "import pdb":
break
else:
vim.current.buffer.append('import pdb', 0)
vim.command('normal j1')
def RemoveBreakpoints():
import re
nCurrentLine = int( vim.eval( 'line(".")'))
nLines = []
nLine = 1
for strLine in vim.current.buffer:
if strLine == 'import pdb' or strLine.lstrip()[:15] == 'pdb.set_trace()':
nLines.append( nLine)
nLine += 1
nLines.reverse()
for nLine in nLines:
vim.command( 'normal %dG' % nLine)
vim.command( 'normal dd')
if nLine < nCurrentLine:
nCurrentLine -= 1
vim.command( 'normal %dG' % nCurrentLine)
def EvaluateCurrentRange():
print "#" * 30
eval(compile('\n'.join(vim.current.range),'','exec'), globals())
print "#" * 30
#vim.command( 'map <s-f7> :py RemoveBreakpoints()<cr>')
#vim.command('map <f7> :py SetBreakpoint()<cr>')
vim.command( 'map <C-h> :py EvaluateCurrentRange()<cr>')
EOF