-
Notifications
You must be signed in to change notification settings - Fork 4
/
vimrc
228 lines (188 loc) · 5.81 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
" THIS IS AN UNHOLY MIX OF STUFF, THINGS AND WOTSITS. USE AT THINE PROPER PERIL.
" Use Vim defaults instead of 100% vi compatibility
set nocompatible
" Disable mode lines to prevent unwanted code execution (CVE-2007-2438)
set modelines=0
" Searching
set ignorecase
set smartcase
set incsearch
map <F7> :set hlsearch!<CR>
" Interface
set ruler
set laststatus=2
set showmode
set showmatch
set showcmd
set nowrap
set listchars=tab:→\ ,extends:»,precedes:«,trail:▒,nbsp:·
set mouse=a
map <F8> :set list!<CR>
" Buffers, tabs and windows
nnoremap <Leader>b :buffers<CR>:buffer<Space>
set splitright
set splitbelow
set tabpagemax=1024
" History
set history=1024
set undolevels=1024
" When editing a file, always jump to the last known cursor position.
autocmd BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$") | exe "normal g`\"" | endif
" Syntax highlighting
color twilight256
syntax on
syntax sync fromstart
set synmaxcol=16384
" Indentation settings
set autoindent
" Do not extend the visual selection beyond the last character.
vnoremap $ $h
" Whitespace settings
set shiftwidth=4
set softtabstop=4
set tabstop=4
set noexpandtab
" Open resource
" Ruby has whitespace other settings
autocmd FileType ruby setlocal ts=2 sts=2 sw=2 expandtab
" Auto-completion
set wildmode=longest,list,full
set wildmenu
" Folding
set foldmethod=marker
" Highlight log levels
highlight Warning ctermfg=yellow
autocmd BufWinEnter * match Warning /^\[warn\].*/
highlight Error ctermfg=red
autocmd BufWinEnter * match Error /^\[\(fatal\|error\|err\)\].*/
highlight Info ctermfg=green
autocmd BufWinEnter * match Info /^\[\(info\|notice\)\].*/
" Do not pollute the working directory with swap and other files
"set directory=~/.vim-tmp,~/.tmp,~/tmp,/var/tmp,/tmp
" From http://www.reddit.com/r/vim/comments/gexi6/a_smarter_statusline_code_in_comments/
function! MyStatusLine(mode)
let statusline=""
if a:mode == 'Enter'
let statusline.="%#StatColor#"
endif
let statusline.="\(%n\)\ %f\ "
if a:mode == 'Enter'
let statusline.="%*"
endif
let statusline.="%#Modified#%m"
if a:mode == 'Leave'
let statusline.="%*%r"
elseif a:mode == 'Enter'
let statusline.="%r%*"
endif
let statusline .= "\ (%l/%L,\ %c)\ %P%=%h%w\ %y\ [%{&encoding}:%{&fileformat}]\ \ "
return statusline
endfunction
"au WinEnter * setlocal statusline=%!MyStatusLine('Enter')
"au WinLeave * setlocal statusline=%!MyStatusLine('Leave')
"set statusline=%!MyStatusLine('Enter')
function! InsertStatuslineColor(mode)
if a:mode == 'i'
hi StatColor guibg=orange ctermbg=lightred
elseif a:mode == 'r'
hi StatColor guibg=#e454ba ctermbg=magenta
elseif a:mode == 'v'
hi StatColor guibg=#e454ba ctermbg=magenta
else
hi StatColor guibg=red ctermbg=red
endif
endfunction
"au InsertEnter * call InsertStatuslineColor(v:insertmode)
"au InsertLeave * hi StatColor guibg=#95e454 guifg=black ctermbg=blue ctermfg=white
"hi StatColor guibg=#95e454 guifg=black ctermbg=blue ctermfg=white
"hi Modified guibg=orange guifg=black ctermbg=blue ctermfg=red
" ^^ ^^ ^^ end of http://www.reddit.com/r/vim/comments/gexi6/a_smarter_statusline_code_in_comments/
" Easier input through insert mode mappings, abbreviations and digraphs
" -----------------------------------------------------------------------------
" Used everywhere, independent of file type.
ab dmp Spoon::dump();<Left><Left>
ab author Davy Hellemans <[email protected]>
ab psf public static function
ab ... …
ab <3 ♥
" Note: <3 is jarring when using XML/HTML, because the cursor does not
" immediately move to the right when typing “<”, because there might be a
" “3” coming up.
dig <3 2665 " ♥
" Related predefined digraphs:
" cS: ♠ = black spade
" cH: ♡ = white heart (think: _c_ard _H_earts)
" cD: ♢ = white diamond
" cC: ♣ = black club
" Map the Mac US QWERTY keyboard combinations; easier than using digraphs
" Note that these conflict pretty badly with any action immediately after
" exiting insert mode. For example: “Oh shit, mistake”, <Esc> to exit insert
" mode, immediately followed by “u” to undo. Either I will retrain myself to
" always use <Esc> twice, or –better yet– fix the bloody terminal to send <Alt>
" instead of <Esc>.
imap <Esc>@ €
imap <Esc>- –
imap <Esc>_ —
imap <Esc>; …
" imap <Esc>g ©
" imap <Esc>r ®
" imap <Esc>p π
" imap <Esc>P Π
" imap <Esc>[ “
" imap <Esc>{ ”
" imap <Esc>] ‘
" imap <Esc>} ’
" Alt+U triggers the ¨ diacritical mark, which will be combined with the next
" character if possible.
" imap <Esc>u ¨
" imap <Esc>ua ä
" imap <Esc>ue ë
" imap <Esc>ui ï
" imap <Esc>uo ö
" imap <Esc>uu ü
" imap <Esc>uy ÿ
" Alt+I triggers the ˆ diacritical mark, which will be combined with the next character if possible
" imap <Esc>i ˆ
" imap <Esc>ia â
" imap <Esc>ie ê
" imap <Esc>ii î
" imap <Esc>io ô
" imap <Esc>iu û
" imap <Esc>iy ÿ
" Shell scripts.
" Print all positional parameters.
autocmd FileType sh,bash :ab foreach for ((i = 0; i <= $#; i++)); do echo "$i: \"${!i}\""; done;
" Use ack for searching.
set grepprg=ack
" Show line numbers and make them 5 characters wide
map <F6> :set number!<CR>
set numberwidth=5
" Show taglist
map <F2> :TlistToggle<CR>
" Show information concerning the current position in the document.
set ruler
" Copy paste from system clipboard
map <C-y> "+y
map <C-p> "+p
" Command-t for the win
map <F5> :CommandT<CR>
"syn on
"set history=1000
"set wildmenu
"set ignorecase
"set smartcase
"set title
"set backspace=indent,eol,start
"set hlsearch
"set incsearch
"set colorcolumn=100
"colorscheme desert
if has("gui_running")
set guioptions=egmrt
endif
filetype plugin indent on
highlight SpecialKey ctermfg=8
" Configuration details for the autocompletion popup
let g:acp_behaviorKeywordLength = 4
" Configuration for easier buffer switching
map <F9> :buffers<CR>:buffer<Space>