-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.vimrc
281 lines (230 loc) · 7.21 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
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
" John's .vimrc
" $Revision: 1.35 $
filetype plugin indent on
if &t_Co > 2 || has("gui_running")
syntax on
endif
set nocompatible " Use Vim defaults
set bs=indent,eol,start
set ai " set autoindenting on
set viminfo='20,\"50 " read/write a .viminfo file, don't store more
set noruler
set ts=4
set shiftwidth=4
set nobackup
set writebackup
set hidden
set wildmenu
set wildmode=list:longest
set shiftround
set tags=tags
set clipboard=unnamed
set lazyredraw
set nojoinspaces
set scrolloff=2
set shortmess=flmnxToOI
set hlsearch
set listchars=eol:$,tab:>-
set cpoptions-=a
let s:swapdir = '~/.vimswap'
execute 'set directory=' . s:swapdir . '//'
if !isdirectory(expand(s:swapdir))
call mkdir(expand(s:swapdir))
endif
if has("win32")
set grepprg=grep\ -nI\ $*\ \\\\|\ sed\ -f\ \"~/vimfiles/grepfilter.sed\"
else
set grepprg=grep\ -nI\ $*\ \\\\|\ sed\ -f\ \"$HOME/.vim/grepfilter.sed\"
endif
" set 'selection', 'selectmode', 'mousemodel' and 'keymodel'
behave mswin
set selectmode= " selections in visual mode (overrides behave mswin)
set mousemodel=extend " right mouse extends selection, left selects
" backspace and cursor keys wrap to previous/next line
set backspace=2
set whichwrap+=<,>,[,]
" extend selection with shift and left mouse button
map <S-LeftMouse> <RightMouse>
map <S-LeftDrag> <RightDrag>
map <S-LeftRelease> <RightRelease>
if has("win32")
set shellpipe=\|\ tee
endif
let mapleader = ' '
" ---------- CVS plugin ----------------------------------------------
let CVSCommandDeleteOnHide = 1
let CVSCommandDiffOpt = ''
" ---------- 2html script --------------------------------------------
let html_use_css = 1
let html_no_display_credit = 0
" ---------- Sessions ------------------------------------------------
" Automatically save session files if Auto_session is set to 1
autocmd VimLeavePre *
\ if (exists("g:Auto_session") && Auto_session != 0) |
\ exe "mksession! Session.vimsession" |
\ endif
set sessionoptions=buffers,curdir,folds,globals,localoptions,options,resize,winpos,winsize
" ---------- Filetypes -----------------------------------------------
" When editing a file, always jump to the last known cursor position.
" Don't do it when the position is invalid or when inside an event handler
" (happens when dropping a file on gvim).
autocmd BufReadPost *
\ if line("'\"") > 0 && line("'\"") <= line("$") |
\ exe "normal g`\"" |
\ endif
" System include files: always open read-only
augroup sysincludes
au!
au BufReadPost c:/program\ files/visual\ studio/vc98/include/*,c:/winddk/2600.1106/inc/*,c:/program\ files/Platform\ sdk/include/*
\ set readonly |
\ set bufhidden=delete |
\ view
augroup END
" Source the current buffer - used to load Sessions
fun! SourceCurrent()
let l:session = expand("%")
bdel
exe "source " . l:session
endf
" ---------- Mappings ------------------------------------------------
nmap <F2> /^\(<<<<<<<\\|=======\\|>>>>>>>\)<CR>
imap <F3> <C-O>:set invlist<CR>
map <F3> :set invlist<CR>
imap <F4> <C-O>:set invhls<CR>
map <F4> :set invhls<CR>
imap <F5> <ESC><F5>
map <F5> :new<CR>:only<CR>"*P:set ft=mail<CR>1G
imap <S-F5> <ESC><S-F5>
map <S-F5> :new<CR>:only<CR>"*P:runtime formatmail.vim<CR>
imap <C-F5> <ESC><C-F5>
map <C-F5> 1GVG"zd:bd!<CR>:let @*=@z<CR>
map <F7> <C-W>}
imap <F7> <C-O><C-W>}i
map <S-F7> :pclose<CR>
imap <S-F7> <C-O>:pclose<CR>
map <F8> :vimgrep <cword> *<CR>
imap <F8> <ESC><F8>
map <S-F8> :vimgrep <cword>
imap <S-F8> <ESC><F8>
map <F9> :bufdo :update<CR>:make<CR>
imap <F9> <ESC><F9>
map <F11> :cn<CR>zv
map <S-F11> :cp<CR>zv
map <F12> :crewind<CR>
inoremap <C-space> <C-N>
" make Ctrl+- work like Ctrl+T (vim terminal strangeness means we specify it
" as <C-_> rather than <C-->
map <C-_> <C-T>
" Alt+] displays tag in preview window
map <M-]> :exe "silent! ptag " . expand("<cword>")<CR>
map <M-[> :exe "silent! pclose"<CR>
" CTRL-Tab is Next window
noremap <C-Tab> <C-W>w
inoremap <C-Tab> <C-O><C-W>w
cnoremap <C-Tab> <C-C><C-W>w
" Y yanks to end of line, rather than the whole line (yy)
map Y yg_
" Don't use Ex mode, use Q for formatting
map Q gq
" backspace in Visual mode deletes selection
vnoremap <BS> d
" proper Windows <C-Del> command
fu! Windows_C_Del()
if (strlen(getline(".")) == col("."))
execute "normal! gJ"
else
execute "normal! dw"
endif
endf
" windows style navigation
imap <C-Del> <C-O>:call Windows_C_Del()<CR>
if !has("win32") || has("gui_running")
imap <C-BS> <C-W>
else
" windows terminal is currently broken and sends C-BS as CS-C
imap <CS-C> <C-W>
endif
map <C-Left> b
map <C-Right> w
imap <C-Left> <C-O>b
imap <C-Right> <C-O>w
" Cursor in Windows Terminal
if has("win32") && !has("gui_running")
let &t_ti.="\e[5 q"
let &t_SI.="\e[5 q"
let &t_EI.="\e[1 q"
let &t_te.="\e[0 q"
endif
" Smart home key
fun! s:SmartHome()
if col('.') != match(getline('.'), '\S')+1
norm ^
else
:call cursor(line('.'),2)
norm h
endif
endfun
inoremap <silent><home> <C-O>:call <SID>SmartHome()<CR>
nnoremap <silent><home> :call <SID>SmartHome()<CR>
vnoremap <silent><home> :call <SID>SmartHome()<CR>
" ctrl+arrow keys scroll the screen up and down without moving the cursor
nmap <C-Up> <C-Y>
nmap <C-Down> <C-E>
imap <C-Up> <C-O><C-Y>
imap <C-Down> <C-O><C-E>
" Insert GUIDS
if has("win32")
imap <silent> <C-G> <C-R>=substitute(system('PrintGuid'), "[\r\n]*$", "", "")<CR>
nmap <C-G> "=substitute(system('PrintGuid'), "[\r\n]*$", "", "")<CR>P
endif
" Commentify
let g:EnhCommentifyUserBindings = 'yes'
let g:EnhCommentifyPretty = 'yes'
let g:EnhCommentifyRespectIndent = 'yes'
let g:EnhCommentifyMultiPartBlocks = 'yes'
vmap <Leader>x <Plug>VisualTraditional
nmap <Leader>x <Plug>Traditional
" Insert copyright
if !has("win32") || has("gui_running")
:imap <CS-C> John Hall <[email protected]><CR>Copyright (c) Midas Yellow Ltd. All rights reserved.<CR>
endif
" ---------- Highlighting -------------------------------------------
if has('gui_running')
set background=dark
colorscheme solarized
else
highlight Normal ctermbg=5
colorscheme default
endif
"hi Identifier ctermfg=gray
"hi Comment ctermfg=cyan
"hi Folded guibg=#d9e9fb guifg=#404040
hi Folded guifg=#d9e9fb guibg=black
let g:yacc_uses_cpp=1
" ---------- Status bar stuff ----------------------------------------
fu! Options()
let opt=""
" autoindent
if &ai| let opt=opt." ai" |endif
" expandtab
if &et| let opt=opt." et" |endif
" paste
if &paste|let opt=opt." paste"|endif
" shiftwidth
let opt=opt." sw=".&shiftwidth
" tabstop
let opt=opt." ts=".&tabstop
" textwidth - show always!
let opt=opt." tw=".&tw
return opt
endf
set statusline=%1*\ [%n]%*\ %(%M%R%H%)\ %(%<%*%f%)\ %y%=%2*%{Options()}\ \%3*<%l,%v>%*\
set laststatus=2
" User1: colour for buffer number
hi User1 cterm=NONE ctermfg=Blue ctermbg=white guifg=SlateBlue guibg=gray80
" User2: colour for modes
hi User2 cterm=NONE ctermfg=DarkGreen ctermbg=white guifg=SeaGreen guibg=gray80
" User3: colour for position
hi User3 cterm=NONE ctermfg=DarkBlue ctermbg=white guifg=SlateBlue guibg=gray80
hi StatusLine cterm=NONE ctermfg=Black ctermbg=white gui=NONE guifg=black guibg=gray80
hi StatusLineNC ctermbg=Gray gui=NONE guibg=gray90