-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvimrc
211 lines (159 loc) · 4.52 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
"
" Nick Bair's Vim Configuration
"
" It's my favorite, because it's mine!
" http://nickbair.net
"
" needed for pathogen to function in jailed shell environments
set shell=/bin/bash
" load pathogen
runtime bundle/vim-pathogen/autoload/pathogen.vim
" update runtimepath variable to load plugins
" from ~/.vim/bundle using pathogen
" and refresh hepltags
call pathogen#infect()
call pathogen#helptags()
" break Vi compatibility and set Vim defaults
set nocompatible
"
" =Display
"
set ruler " always show cursor position in status bar
set showcmd " show commands while typing
set number " show line numbers
set showtabline=2 " always show tab bar
" set font and colors
if has('win32')
set guifont=Consolas:h11
else
set guifont=Menlo\ 11
endif
set background=dark
let g:solarized_termtrans=1
colorscheme solarized
"
" =Syntax Highlighting
"
" enable syntax highlighting in color terminals
if &t_Co > 2 || has('gui_running')
syntax on
endif
"
" =Formatting
"
" auto-indenting (based on filetype if available)
if has('autocmd')
filetype plugin indent on
else
set autoindent
endif
set textwidth=80 " line breaks at column 80
set formatoptions+=tcroql " see :h fo and :h fo-table
set linebreak " only break lines at certain character types
set nowrap " don't soft-wrap lines (it makes coding hard)
set tabstop=4 " tab size for tab key
set shiftwidth=4 " tab size for >> and << and autoindent
set expandtab " use spaces instead of tabs
highlight ColorColumn ctermbg=cyan
call matchadd('ColorColumn', '\%81v', 100)
highlight SpecialKey ctermbg=none ctermfg=4
exec "set listchars=tab:\uBB\u2014,nbsp:~,trail:\uB7"
set list
"
" =Search
"
set incsearch " incremental searching (find as you type)
set ignorecase " case-insensitive searches
set nohlsearch " do not highlight search results
function! HLNext (blinktime)
highlight WhiteOnRed ctermfg=white ctermbg=red
let [bufnum, lnum, col, off] = getpos('.')
let matchlen = strlen(matchstr(strpart(getline('.'),col-1),@/))
let target_pat = '\c\%#'.@/
let ring = matchadd('WhiteOnRed', target_pat, 101)
redraw
exec 'sleep ' . float2nr(a:blinktime * 1000) . 'm'
call matchdelete(ring)
redraw
endfunction
"
" =Folding
"
set foldmethod=indent
set nofoldenable
set foldlevel=1
"
" =Misc
"
" allow backspacing over everything in insert mode
set backspace=indent,eol,start
" command line history
set history=50
" auto-save files when switching buffers
set autowrite
if has('autocmd')
" create & initialize new autocmd group 'misc'
augroup misc
" clear group
autocmd!
" remember last known cursor position
autocmd BufReadPost *
\ if line("'\"") > 1 && line("'\"") <= line("$") |
\ exec "normal! g`\"" |
\ endif
autocmd BufEnter * lcd %:p:h
" misc. filetypes
autocmd BufRead,BufNewFile *.tpl set filetype=php
augroup end
augroup NoSimultaneousEdits
autocmd!
autocmd SwapExists * let v:swapchoice = 'o'
autocmd SwapExists * echo 'Duplicate edit session (readonly)'
autocmd SwapExists * echohl None
autocmd SwapExists * sleep 2
augroup end
endif
" enable mouse
set mouse=a
"
" =Abbreviations
"
" expand %% to [current directory] in command mode
cabbr <expr> %% expand('%:p:h')
"
" =Commands
"
" diff the current buffer with the file from which it was loaded
if !exists(":DiffOrig")
command DiffOrig vert new | set bt=nofile | r # | 0d_ | diffthis |
wincmd p | diffthis
endif
"
" =Keymappings
"
" break undo on line breaks in insert mode
inoremap <C-U> <C-G>u<C-U>
" save keystrokes by remapping ; to :
nnoremap ; :
" expand \e to :e [current directory] in normal mode
nnoremap <Leader>e :e <C-R>=expand('%:p:h') . '/'<CR>
" expand \w to the specified path
nnoremap <Leader>w :e ~/Projects/Web/
" tab shortcuts
nnoremap ,0 :tabfirst<CR>
nnoremap ,l :tabnext<CR>
nnoremap ,h :tabprevious<CR>
nnoremap ,$ :tablast<CR>
nnoremap ,x :tabclose<CR>
nnoremap ,m :tabmove
" map \nt to open/close NERDTree
nnoremap <Leader>nt :NERDTreeTabsToggle<CR>
" highlight next search term for easy finding
nnoremap <silent> n n:call HLNext(0.4)<cr>
nnoremap <silent> N N:call HLNext(0.4)<cr>
" keybindings for dragvisuals.vim
vmap <expr> <LEFT> DVB_Drag('left')
vmap <expr> <RIGHT> DVB_Drag('right')
vmap <expr> <DOWN> DVB_Drag('down')
vmap <expr> <UP> DVB_Drag('up')
vmap <expr> D DVB_Duplicate()