-
Notifications
You must be signed in to change notification settings - Fork 0
/
vimrc
182 lines (148 loc) · 4.33 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
set nocompatible
filetype off
set rtp+=~/.vim/bundle/vundle
call vundle#rc()
Bundle 'gmarik/vundle'
Bundle 'kien/ctrlp.vim.git'
Bundle 'markabe/bufexplorer'
Bundle 'edsono/vim-matchit'
Bundle 'scrooloose/nerdtree'
Bundle 'ervandew/supertab'
Bundle 'godlygeek/tabular'
Bundle 'altercation/vim-colors-solarized'
Bundle 'pangloss/vim-javascript'
Bundle 'hallison/vim-markdown'
Bundle 'tpope/vim-rails'
Bundle 'tpope/vim-repeat'
Bundle 'tpope/vim-surround'
Bundle 'scrooloose/nerdcommenter'
Bundle 'jherdman/snipmate.vim'
Bundle 'majutsushi/tagbar'
Bundle 'devbox-dark-256'
Bundle 'nathanaelkane/vim-indent-guides'
Bundle 'vim-scripts/VimClojure'
Bundle 'tpope/vim-cucumber'
" Required for Vundle
filetype plugin indent on
let mapleader=","
" Quickly edit/reload the vimrc file
nmap <silent> <leader>ev :e $MYVIMRC<CR>
nmap <silent> <leader>sv :so $MYVIMRC<CR>
" Other basic settings
set nocompatible
set ruler
set showcmd
set spell
set nowrap
set smarttab
set autoindent
set tabstop=2
set shiftwidth=2
set expandtab
set backspace=eol,start,indent " backspacing over everything in insert mode"
set hlsearch " highlight search terms"
set incsearch " show search mates as you type"
set ignorecase " ignore case when searching, but...
set smartcase " only when I'm using all lowercase search terms"
set tags=tags " look in root of project, and work your way up
set backupdir=~/.tmp
set number
" Now you can do ";w" instead of ":w"
nnoremap ; :
if &t_Co > 2 || has("gui_running")
syntax on
endif
" Color scheme
if has("gui_running")
set background=dark
colorscheme solarized
set lines=48
set columns=85
" Hide the toolbar, but show tabs
set guioptions=egmrt
else
colorscheme devbox-dark-256
endif
" Disable ex mode
map Q <Nop>
" Configurations that are system sensitive
if has("win32")
map <C-T> <Esc>:tabnew<CR>
set guifont=Consolas:h12:cANSI
else
set guifont=Menlo:h16
endif
" Always use UNIX format
set fileformats=unix,dos
" Remove extra whitespace
function! <SID>StripTrailingWhitespaces()
" Preparation: save last search, and cursor position.
let _s=@/
let l = line(".")
let c = col(".")
" Do the business:
%s/\s\+$//e
" Clean up: restore previous search history, and cursor position
let @/=_s
call cursor(l, c)
endfunction
nnoremap <silent> <F6> :call <SID>StripTrailingWhitespaces()<CR>
" Use the same symbols as TextMate for tabstops and EOLs
set listchars=tab:▸\ ,eol:¬
command! -nargs=* Wrap set wrap linebreak nolist
set showbreak=…
" Don't use Ex mode, use Q for formatting
map Q gq
" Softwrap mappings with command key
vmap <D-j> gj
vmap <D-k> gk
vmap <D-4> g$
vmap <D-6> g^
vmap <D-0> g^
nmap <D-j> gj
nmap <D-k> gk
nmap <D-4> g$
nmap <D-6> g^
nmap <D-0> g^
" Splits
"" Window
nmap <leader>sw<left> :topleft vnew<CR>
nmap <leader>sw<right> :botright vnew<CR>
nmap <leader>sw<up> :topleft new<CR>
nmap <leader>sw<down> :botright new<CR>
"" Buffer
nmap <leader>s<left> :leftabove vnew<CR>
nmap <leader>s<right> :rightbelow vnew<CR>
nmap <leader>s<up> :leftabove new<CR>
nmap <leader>s<down> :rightbelow new<CR>
" Open a method def via Ctags in a vertical split
map <C-\> :vsp <CR>:exec("tag ".expand("<cword>"))<CR>
" Clear search buffer
nmap <silent> <leader>/ :let @/=""<CR>
" Find and replace text under cursor
" http://vim.wikia.com/wiki/Search_and_replace_the_word_under_the_cursor
nnoremap <Leader>s :%s/\<<C-r><C-w>\>/
" Toggle comments
map <D-/> <plug>NERDCommenterToggle
" Tabularize settings
nmap <Leader>a= :Tabularize /=<CR>
vmap <Leader>a= :Tabularize /=<CR>
nmap <Leader>a: :Tabularize /:\zs<CR>
vmap <Leader>a: :Tabularize /:\zs<CR>
" NERDTree convenience
map <F2> :NERDTreeToggle<CR>
function! s:align()
let p = '^\s*|\s.*\s|\s*$'
if exists(':Tabularize') && getline('.') =~# '^\s*|' && (getline(line('.')-1) =~# p || getline(line('.')+1) =~# p)
let column = strlen(substitute(getline('.')[0:col('.')],'[^|]','','g'))
let position = strlen(matchstr(getline('.')[0:col('.')],'.*|\s*\zs.*'))
Tabularize/|/l1
normal! 0
call search(repeat('[^|]*|',column).'\s\{-\}'.repeat('.',position),'ce',line('.'))
endif
endfunction
" Treat Thor files like Ruby
au BufRead,BufNewFile {Capfile,Thorfile,Guardfile,*.thor,*.rabl} set ft=ruby
" Tagbar
let g:tagbar_ctags_bin = "/usr/local/bin/ctags"
map <F3> :TagbarToggle<CR>