-
Notifications
You must be signed in to change notification settings - Fork 0
/
.vimrc
executable file
·203 lines (153 loc) · 4.58 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
" must be first, changes behaviour of other settings
set nocompatible
" 256 colors
set t_Co=256
" sane text files
set fileformat=unix
set encoding=utf-8
" sane tabs
set tabstop=4
set shiftwidth=4
set softtabstop=4
" convert all typed tabs to spaces
set expandtab
" syntax highlighting
syntax on
color koehler
"make sure highlighting works all the way down long files
autocmd BufEnter * :syntax sync fromstart
" allow cursor to be positioned one char past end of line
" and apply operations to all of selection including last char
set selection=exclusive
" allow backgrounding buffers without writing them
" and remember marks/undo for backgrounded buffers
set hidden
" Keep more context when scrolling off the end of a buffer
set scrolloff=3
" allow cursor keys to go right off end of one line, onto start of next
set whichwrap+=<,>,[,]
" allow backspacing over everything in insert mode
set backspace=indent,eol,start
" no line wrapping
set nowrap
" line numbers
set number
" when joining lines, don't insert two spaces after punctuation
set nojoinspaces
" Make searches case-sensitive only if they contain upper-case characters
set ignorecase
set smartcase
" show search matches as the search pattern is typed
set incsearch
" search-next wraps back to start of file
set wrapscan
" highlight last search matches
set hlsearch
" map key to dismiss search highlightedness
map <bs> :noh<CR>
" grep for word under cursor
noremap <Leader>g :grep -rw '<C-r><C-w>' .<CR>
" aliases for window switching (browser captures ctrl-w)
noremap <C-l> <C-w>l
noremap <C-h> <C-w>h
noremap <C-k> <C-w>k
noremap <C-j> <C-w>j
" similarly ctrl-q doesnt work, so use leader-q for block visual mode
nnoremap <leader>q <C-Q>
" make tab completion for files/buffers act like bash
set wildmenu
" display cursor co-ords at all times
set ruler
set cursorline
" display number of selected chars, lines, or size of blocks.
set showcmd
" show matching brackets, etc, for 1/10th of a second
set showmatch
set matchtime=1
" enables filetype specific plugins
filetype plugin on
" enables filetype detection
filetype on
if has("autocmd")
" Enable file type detection.
" Use the default filetype settings, so that mail gets 'tw' set to 72,
" 'cindent' is on in C files, etc.
" Also load indent files, to automatically do language-dependent indenting.
filetype plugin indent on
" 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
else
" if old vim, set vanilla autoindenting on
set autoindent
endif " has("autocmd")
" enable automatic yanking to and pasting from the selection
set clipboard+=unnamed
" places to look for tags files:
set tags=./tags,tags
" recursively search file's parent dirs for tags file
" set tags+=./tags;/
" recursively search cwd's parent dirs for tags file
set tags+=tags;/
"autocompletion
inoremap <c-space> <c-n>
inoremap <c-s-space> <c-p>
" =====STATUS LINE OF DEATH!!=====
set statusline=
" filename, relative to cwd
set statusline+=%f
" separator
set statusline+=\
" modified flag
set statusline+=%#wildmenu#
set statusline+=%m
set statusline+=%*
"Display a warning if file encoding isnt utf-8
set statusline+=%#question#
set statusline+=%{(&fenc!='utf-8'&&&fenc!='')?'['.&fenc.']':''}
set statusline+=%*
"display a warning if fileformat isnt unix
set statusline+=%#directory#
set statusline+=%{&ff!='unix'?'['.&ff.']':''}
set statusline+=%*
"display a warning if files contains tab chars
set statusline+=%#warningmsg#
set statusline+=%{StatuslineTabWarning()}
set statusline+=%*
" read-only
set statusline+=%r
set statusline+=%*
" right-align
set statusline+=%=
" filetype
set statusline+=%{strlen(&ft)?&ft:'none'}
" separator
set statusline+=\
" current char
set statusline+=%3b,0x%02B
" separator
set statusline+=\
" column,
set statusline+=%2c,
" current line / lines in file
set statusline+=%l/%L
" always show status line
set laststatus=2
" return '[tabs]' if tab chars in file, or empty string
function! StatuslineTabWarning()
if !exists("b:statusline_tab_warning")
let tabs = search('^\t', 'nw') != 0
if tabs
let b:statusline_tab_warning = '[tabs]'
else
let b:statusline_tab_warning = ''
endif
endif
return b:statusline_tab_warning
endfunction
"recalculate the tab warning flag when idle and after writing
autocmd cursorhold,bufwritepost * unlet! b:statusline_tab_warning