-
Notifications
You must be signed in to change notification settings - Fork 0
/
dot_vimrc
168 lines (151 loc) · 5.73 KB
/
dot_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
color blue
syntax on
set shiftwidth=4
set tabstop=8
set softtabstop=4
set foldenable
set foldmethod=manual
set noremap
set expandtab
set colorcolumn=81
"set list listchars=tab:>-,trail:.,eol:$
set list listchars=tab:>-,trail:.
set list
" use both cscope and ctag for 'ctrl-]', ':ta', and 'vim -t'
set cscopetag
" check cscope for definition of a symbol before checking ctags: set to 1
" if you want the reverse search order.
set csto=1
set tags=./tags,tags
if executable("cscope") > 0
" add any cscope database in current directory
if filereadable("cscope.out")
cs add cscope.out
" else add the database pointed to by environment variable
elseif filereadable("/home/yama/cscope.out")
cs add /home/yama/cscope.out
elseif filereadable("/home/yama/proj/cscope.out")
cs add /home/yama/proj/cscope.out
elseif $CSCOPE_DB != ""
cs add $CSCOPE_DB
endif
endif
"
" cscope mappings
nmap <C-_>s :cs find s <C-R>=expand("<cword>")<CR><CR>
nmap <C-_>g :cs find g <C-R>=expand("<cword>")<CR><CR>
nmap <C-_>c :cs find c <C-R>=expand("<cword>")<CR><CR>
nmap <C-_>t :cs find t <C-R>=expand("<cword>")<CR><CR>
nmap <C-_>e :cs find e <C-R>=expand("<cword>")<CR><CR>
nmap <C-_>f :cs find f <C-R>=expand("<cfile>")<CR><CR>
nmap <C-_>i :cs find i ^<C-R>=expand("<cfile>")<CR>$<CR>
nmap <C-_>d :cs find d <C-R>=expand("<cword>")<CR><CR>
" Using 'CTRL-spacebar' then a search type makes the vim window
" split horizontally, with search result displayed in
" the new window.
nmap <C-Space>s :scs find s <C-R>=expand("<cword>")<CR><CR>
nmap <C-Space>g :scs find g <C-R>=expand("<cword>")<CR><CR>
nmap <C-Space>c :scs find c <C-R>=expand("<cword>")<CR><CR>
nmap <C-Space>t :scs find t <C-R>=expand("<cword>")<CR><CR>
nmap <C-Space>e :scs find e <C-R>=expand("<cword>")<CR><CR>
nmap <C-Space>f :scs find f <C-R>=expand("<cfile>")<CR><CR>
nmap <C-Space>i :scs find i ^<C-R>=expand("<cfile>")<CR>$<CR>
nmap <C-Space>d :scs find d <C-R>=expand("<cword>")<CR><CR>
" Hitting CTRL-space *twice* before the search type does a vertical
" split instead of a horizontal one
nmap <C-_><C-_>s :vert scs find s <C-R>=expand("<cword>")<CR><CR>
nmap <C-_><C-_>g :vert scs find g <C-R>=expand("<cword>")<CR><CR>
nmap <C-_><C-_>c :vert scs find c <C-R>=expand("<cword>")<CR><CR>
nmap <C-_><C-_>t :vert scs find t <C-R>=expand("<cword>")<CR><CR>
nmap <C-_><C-_>e :vert scs find e <C-R>=expand("<cword>")<CR><CR>
nmap <C-_><C-_>i :vert scs find i ^<C-R>=expand("<cfile>")<CR>$<CR>
nmap <C-_><C-_>d :vert scs find d <C-R>=expand("<cword>")<CR><CR>
set showtabline=2 " 0, 1 or 2; when to use a tab pages line
set tabline=%!MyTabLine() " custom tab pages line
function MyTabLine()
let s = '' " complete tabline goes here
" loop through each tab page
for t in range(tabpagenr('$'))
" set highlight for tab number and &modified
let s .= '%#TabLineSel#'
" set the tab page number (for mouse clicks)
let s .= '%' . (t + 1) . 'T'
" set page number string
let s .= t + 1 . ':'
" get buffer names and statuses
let n = '' "temp string for buffer names while we loop and check buftype
let m = 0 " &modified counter
let bc = len(tabpagebuflist(t + 1)) "counter to avoid last ' '
" loop through each buffer in a tab
for b in tabpagebuflist(t + 1)
" buffer types: quickfix gets a [Q], help gets [H]{base fname}
" others get 1dir/2dir/3dir/fname shortened to 1/2/3/fname
if getbufvar( b, "&buftype" ) == 'help'
let n .= '[H]' . fnamemodify( bufname(b), ':t:s/.txt$//' )
elseif getbufvar( b, "&buftype" ) == 'quickfix'
let n .= '[Q]'
else
let n .= pathshorten(bufname(b))
endif
" check and ++ tab's &modified count
if getbufvar( b, "&modified" )
let m += 1
endif
" no final ' ' added...formatting looks better done later
if bc > 1
let n .= ' '
endif
let bc -= 1
endfor
" add modified label [n+] where n pages in tab are modified
if m > 0
let s .= '[' . m . '+]'
endif
" select the highlighting for the buffer names
" my default highlighting only underlines the active tab
" buffer names.
if t + 1 == tabpagenr()
let s .= '%#TabLine#'
else
let s .= '%#TabLineSel#'
endif
" add buffer names
let s .= n
" switch to no underlining and add final space to buffer list
let s .= '%#TabLineSel#' . ' '
endfor
" after the last tab fill with TabLineFill and reset tab page nr
let s .= '%#TabLineFill#%T'
" right-align the label to close the current tab page
if tabpagenr('$') > 1
let s .= '%=%#TabLineFill#%999Xclose'
endif
return s
endfunction
set runtimepath^=/home/ymaslenn/opt/vim-erlang-tags
"enable mouse in vim
set mouse=a
"autodetect filtype YANG
au BufRead,BufNewFile *.yang setf yang
" some other useful file types
au BufRead,BufNewFile {confd,ncs}.conf setf xml
au BufRead,BufNewFile netconf*trace setf xml
au BufRead,BufNewFile *.yang setf yang
au BufRead,BufNewFile *.{log,txt} set colorcolumn=
" autoopen confderr.log, ncserr.log
au BufReadCmd,FileReadCmd {confd,ncs}err.log.[0-9]*
\ read ! ${TRUNK}/bin/confd --printlog "<afile>:r" ||
\ ${TRUNK}/bin/confd --printlog "<afile>"
au BufReadCmd,FileReadCmd {confd,ncs}err.log
\ read ! ${TRUNK}/bin/confd --printlog "<afile>"
au BufReadCmd,FileReadCmd {confd,ncs}err.log.
\ read ! ${TRUNK}/bin/confd --printlog "<afile>:r"
au BufReadCmd {confd,ncs}err.log* :1
au BufReadCmd {confd,ncs}err.log* :d
" autoopen debug-dump
" file name must be <filename>.dump
au BufReadCmd,FileReadCmd *.dump
\ read ! ${TRUNK}/bin/confd --show-debug-dump "<afile>"
au BufReadCmd *.dump :1
au BufReadCmd *.dump :d
au FileType yang :syntax sync fromstart