-
Notifications
You must be signed in to change notification settings - Fork 0
/
vimrc
184 lines (142 loc) · 4.28 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
" Use Vim settings, rather then Vi settings (much better!).
" This must be first, because it changes other options as a side effect.
set nocompatible
filetype off
set rtp+=~/.vim/bundle/vundle
call vundle#begin()
Plugin 'altercation/vim-colors-solarized'
Plugin 'bogado/file-line'
Plugin 'chr4/nginx.vim'
Plugin 'ctrlpvim/ctrlp.vim'
Plugin 'ludovicchabant/vim-lawrencium'
Plugin 'pearofducks/ansible-vim'
Plugin 'scrooloose/nerdcommenter'
Plugin 'scrooloose/nerdtree'
Plugin 'tpope/vim-rails'
Plugin 'tpope/vim-rake'
Plugin 'tpope/vim-sensible'
Plugin 'vim-airline/vim-airline'
Plugin 'vim-airline/vim-airline-themes'
call vundle#end()
set modelines=0
set showmode
set hidden
set visualbell
set cursorline
set ttyfast
set showmatch
set hlsearch
set noai
" wrapping options
set wrap
set formatoptions=qn1
let mapleader = ","
nnoremap / /\v
vnoremap / /\v
" map ,<space> to clear command line
nnoremap <leader><space> :noh<cr>
" show whitespace characters
set list
set listchars=tab:▸\ ,eol:¬
" set j & k to move by screen line
nnoremap j gj
nnoremap k gk
nnoremap ; :
set nobackup
set nowritebackup
set showcmd " display incomplete commands
" Don't use Ex mode, use Q for formatting
map Q gq
if has("folding")
set foldenable
set foldmethod=syntax
set foldlevel=1
set foldnestmax=2
set foldtext=strpart(getline(v:foldstart),0,50).'\ ...\ '.substitute(getline(v:foldend),'^[\ #]*','','g').'\ '
endif
" Softtabs, 2 spaces
set tabstop=2
set shiftwidth=2
set softtabstop=4
set expandtab
" Visual mode: D
vmap D y'>p
" Local config
if filereadable(".vimrc.local")
source .vimrc.local
endif
" Use Ack instead of Grep when available
if executable("ack")
set grepprg=ack\ -H\ --nogroup\ --nocolor
endif
" Color scheme
set background=dark
highlight NonText guibg=#060606
highlight Folded guibg=#0A0A0A guifg=#9090D0
" enable solarized if it exists
silent! colorscheme solarized
" Airline
let g:airline_powerline_fonts=1
let g:airline#extensions#branch#enabled=1
let g:airline_theme = 'solarized'
" Numbers
set number
set numberwidth=5
" Tab completion options
" (only complete to the longest unambiguous match, and show a menu)
set completeopt=longest,menu
set wildmode=list:longest,list:full
" case only matters with mixed case expressions
set ignorecase
set smartcase
if has("autocmd")
" PHP hacks
" highlights interpolated variables in sql strings and does sql-syntax highlighting. yay
autocmd FileType php let php_sql_query=1
" does exactly that. highlights html inside of php strings
autocmd FileType php let php_htmlInStrings=1
" discourages use oh short tags. c'mon its deprecated remember
autocmd FileType php let php_noShortTags=1
" automagically folds functions & methods. this is getting IDE-like isn't
autocmd FileType php let php_folding=1
" Drupal *.module, *.inc and *.install files.
augroup module
autocmd BufRead,BufNewFile *.module set filetype=php
autocmd BufRead,BufNewFile *.inc set filetype=php
autocmd BufRead,BufNewFile *.install set filetype=php
augroup END
endif
""""""""""""""""""""""""""""""""""""""""""""""""""
" Custom commands
""""""""""""""""""""""""""""""""""""""""""""""""""
" W strips trailing whitespace
nnoremap <leader>W :%s/\s\+$//<cr>:let @/=''<CR>
" U converts file to unix style endings and saves
nnoremap <leader>U :set ff=unix<cr>:wq<cr>
" S sorts CSS properties alphabetically
nnoremap <leader>S ?{<CR>jV/^\v\s*\}?$<CR>k:sort<CR>:noh<CR>
" V relects text that was just pasted in
nnoremap <leader>v V`]
" jj exits insert mode
inoremap jj <ESC>
" L clears the highlighting of :set hlsearch
nnoremap <leader>l :nohlsearch<C-R>=has('diff')?'<Bar>diffupdate':''<CR><CR><C-L>
" w opens a new vertical window and switches to it
nnoremap <leader>w <C-w>v<C-w>l
" mappings for moving between tabs easily
nnoremap <C-h> <C-w>h
nnoremap <C-j> <C-w>j
nnoremap <C-k> <C-w>k
nnoremap <C-l> <C-w>l
" Ctrl+n toggles NERDTree
map <C-n> :NERDTreeToggle<cr>
" F3 disables autoindenting and autocommenting
nnoremap <F3> :setl noai nocin nosi formatoptions-=c formatoptions-=r formatoptions-=o inde=<CR>
" F4 toggles line numbers and visible whitespace
nnoremap <F4> :setlocal number! list!<CR>
" Lawrencium - Mercurial shortcuts
map <Leader>ha :Hgannotate<CR>
map <Leader>hc :Hgcommit<CR>
map <Leader>hd :Hgvdiff<CR>
map <Leader>hl :Hglogthis<CR>
map <Leader>hs :Hgstatus<CR>