-
Notifications
You must be signed in to change notification settings - Fork 15
/
vimrc
220 lines (166 loc) · 5.57 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
filetype off
call pathogen#runtime_append_all_bundles()
call pathogen#helptags()
" Environment
set nocompatible " don't limit vim trying to support vi
set encoding=utf-8 " set encoding to utf-8
set showmode " show which mode
set showcmd " show last command
set visualbell " flash screen for invalid operation
set mouse=a " allow for full mouse support
set ruler " show ruler
set clipboard=unnamed
set modelines=0 " disabled for security
set cul " highlight line the cursor is on
set ttyfast " fast terminal connection is in use, more redraws allowed
set nolazyredraw " prevent redraw while executing macros
set autowriteall " write changes when switching buffers
set number
set rulerformat=%30(%=\:b%n%y%m%r%w\ %l,%c%V\ %P%)
set statusline=%<%f\ %h%m%r%{fugitive#statusline()}%=%-14.(%l,%c%V%)\ %P
set term=xterm-256color " allow for more color
color jellybeans
" Vim 7.3
if exists("&colorcolumn")
set colorcolumn=115
" Persistent undo setup
set undodir=~/.vim/undodir
set undofile
endif
" Change leader key to , instead of \ (easier to type)
let mapleader=","
" Fast write to file
nmap <leader>w :up<cr>
nmap <leader>u :up<cr>
" Allow saving when you forgot sudo
cmap w!! w !sudo tee % >/dev/null
" Fast switching between tabs
map <leader>. :tabn<cr>
" Fast switching between prev buffer
map <leader>b :b#<cr>
" Fast switching between windows
map <leader>, <C-w>w
map <leader>h <C-w>h
map <leader>j <C-w>j
map <leader>k <C-w>k
map <leader>l <C-w>l
" Fast switching out of insert mode
imap jj <Esc>
" Map Y to match C and D
nmap Y y$
" Yank entire file (global yank)
nmap gy ggVGy
" Use syntax highlighting
syntax on
" Disable word wrapping
set nowrap
" Show addition lines below or above the cursor when scrolling
set scrolloff=3
" Expand all tabs to two spaces
set tabstop=2
set shiftwidth=2
set softtabstop=2
set expandtab
set autoindent
" Show · for trailing space, \ \ for trailing tab
set list listchars=tab:\ \ ,trail:·
" Searching
set hlsearch " highlight search result
set incsearch " show matches while typing
set ignorecase " ignore case when searching
set smartcase " honor case if any uppercase letters are used
set showmatch " jump to match if visible
set magic " make regular expressions follow more closely to perl conventions
" Fast clear highlight
nnoremap <leader><space> :noh<cr>
" Prevent hitting F1 (:h) when trying to ESC
inoremap<F1> <ESC>
nnoremap<F1> <ESC>
vnoremap<F1> <ESC>
" Tab completion
set wildmode=list:longest,list:full
set wildignore+=*.o,.git
" Status bar
set laststatus=2
" Make Vim ignore lines when going up or down
nnoremap j gj
nnoremap k gk
" Make x store in the same register
noremap x "_x
" NERDTree configuration, ignore files ending in ~
let NERDTreeIgnore=['\~$']
map <leader>n :NERDTreeToggle<cr>
" Command-T configuration
let g:CommandTMaxHeight=20
" Ack configuration
nnoremap <leader>a :Ack
let g:ackprg="ack-grep -H --nocolor --nogroup --column"
" CoffeeScript compile
let coffee_compile_on_save = 1
" Syntastic configuration
nnoremap <leader>err :Errors<cr><C-W>w
" MRU configuration
map <leader>m :MRU<cr>
let MRU_Exclude_Files = '^/tmp/.*\|^/var/tmp/.*|COMMIT_EDITMSG'
" ZoomWin configuration
map <leader>z :ZoomWin<cr>
" delimitMate configuration
let loaded_delimitMate = 0
let delimitMate_expand_cr = 1
" CTags
map <leader>rt :!ctags --extra=+f -R *<cr><cr>
" VimOrganizer configuration
let g:org_todo_setup='TODO | DONE'
let g:org_tag_setup='{@home(h) @work(w) @tennisclub(t)} \n {easy(e) hard(d)} \n {computer(c) phone(p)}'
au! BufRead,BufWrite,BufWritePost,BufNewFile *.org
au BufRead,BufNewFile *.org call org#SetOrgFileType()
au BufRead *.org :PreLoadTags
au BufWrite *.org :PreWriteTags
au BufWritePost *.org :PostWriteTags
au BufRead,BufNewFile *.org color org_dark
" Remember last location in file
if has("autocmd")
au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$")
\| exe "normal g'\"" | endif
endif
function s:setupWrapping()
set wrap
set wm=2
set textwidth=72
endfunction
function s:setupMarkup()
call s:setupWrapping()
map <buffer> <leader>p :Mm <cr>
endfunction
" make and python use real tabs
au FileType make set noexpandtab
au FileType python set noexpandtab
" md, markdown, and mk are markdown and define buffer-local preview
au BufRead,BufNewFile *.{md,markdown,mdown,mkd,mkdn} call s:setupMarkup()
" txt files have special wrapping
au BufRead,BufNewFile *.txt call s:setupWrapping()
" allow backspacing over everything in insert mode
set backspace=indent,eol,start
" load the plugin and indent settings for the detected filetype
filetype plugin indent on
" Opens an edit command with the path of the currently edited file filled in
" Normal mode: <leader>e
map <leader>e :e <C-R>=expand("%:p:h") . "/" <cr>
" Opens a tab edit command with the path of the currently edited file filled in
" Normal mode: <leader>t
map <leader>te :tabe <C-R>=expand("%:p:h") . "/" <cr>
" Open a terminal in the current directory
map <leader>gt :!gnome-terminal --working-directory=<C-R>=expand("%:p:h") <cr> <cr> <cr>
" Inserts the path of the currently edited file into a command
" Command mode: Ctrl+P
cmap <C-P> <C-R>=expand("%:p:h") . "/" <cr>
" Strip all trailing whitespace in the current file
nnoremap <leader>W :%s/\s\+$//<cr>:let @/=''<cr>
" Sort CSS properties alphabetically
nnoremap <leader>S ?{<cr>jV/^\s*\}<cr>k:sort<cr>:noh<cr>
" Automatically save file on focus change
au FocusLost * :up
" Easily edit this file
nnoremap <leader>ev <C-w><C-v><C-l>:e $MYVIMRC<cr>
" Source this file after editing
au! BufWritePost .vimrc source ~/.vimrc