forked from ryanb/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vimrc
165 lines (127 loc) · 3.12 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
" mostlyrecommended from http://items.sjbach.com/319/configuring-vim-right
" no vi compatibility
" ~/.vim/autoload/pathogen.vim
execute pathogen#infect()
set nocompatible
" prevent some modelines sec exploits
set modelines=0
" manage buffers correctly
set hidden
" remap ` to '
nnoremap ' `
nnoremap ` '
" set very magic searching (more natural)
nnoremap / /\v
vnoremap / /\v
" map leader to <SPACE>
let mapleader = " "
" more history
set history=1000
" extended % matching
runtime macros/matchit.vim
" useful file/cmd completion
set wildmenu
set wildmode=list:longest
" case-smart searching
set ignorecase
set smartcase
" auto-sub all matches on the line ("g")
set gdefault
" terminal title
set title
" context around cursor
set scrolloff=3
" temp files in one dir
set backupdir=~/.vim-tmp,~/.tmp,~/tmp,/var/tmp,/tmp
set directory=~/.vim-tmp,~/.tmp,~/tmp,/var/tmp,/tmp
" get rid of that Gd F1 key
inoremap <F1> <ESC>
nnoremap <F1> <ESC>
vnoremap <F1> <ESC>
" map ; to :
nnoremap ; :
" faster viewport scrolling
nnoremap <C-e> 3<C-e>
nnoremap <C-y> 3<C-y>
" limited line-numbers
set ruler
" line nos
set number
" Intuitive backspacing in insert mode
set backspace=indent,eol,start
" tabs are 2 spaces
set tabstop=2
set softtabstop=2
set shiftwidth=2
set smarttab
set autoindent
set expandtab
" show mode in Insert/Replace/Visual
set showmode
" always show status line
set laststatus=2
" keep an undofile across sessions
set undofile
" File-type highlighting and configuration.
syntax enable
if has("autocmd")
filetype on
filetype plugin on
filetype indent on
" Restore cursor pos
autocmd BufReadPost *
\ if line("'\"") > 1 && line("'\"") <= line("$") |
\ exe "normal! g`\"" |
\ endif
" auto-save on focus lost
autocmd FocusLost * :wa
endif
" vim starts too slow in jruby
if !empty(matchstr($MY_RUBY_HOME, 'jruby'))
let g:ruby_path = join(split(glob($MY_RUBY_HOME.'/lib/ruby/*.*')."\n".glob($MY_RUBY_HOME.'/lib/rubysite_ruby/*'),"\n"),',')
endif
" use ag instead of ack
if executable('ag')
let g:ackprg = 'ag --nogroup --nocolor --column'
cnoreabbrev ag Ack
cnoreabbrev ack Ack
cnoreabbrev aG Ack
cnoreabbrev Ag Ack
cnoreabbrev AG Ack
endif
" highlight search terms, matching brackets
set hlsearch
set incsearch
set showmatch
" turnoff highlighting
nnoremap <leader><space> :nohl<cr>
" tab jumps to matching bracket
nnoremap <tab> %
vnoremap <tab> %
" chg shortmess (help :shortmess for details)
set shortmess=atI
" silent bell
set errorbells
set visualbell
" faster redrawing
set ttyfast
" customize some colors
hi Comment term=bold ctermfg=yellow ctermbg=blue
hi Pmenu ctermbg=13 guibg=Magenta
" Command-T mappings
let g:CommandTMaxHeight = 30
let g:CommandTMaxFiles = 40000
let g:CommandTFileScanner = 'git'
map <leader>f :CommandT<CR>
map <leader>b :CommandTBuffer<CR>
map <leader>d :execute 'NERDTreeToggle ' . getcwd()<CR>
map <leader>v :!approvals verify -d vimdiff -a<cr>
map <C-N> :cnext<CR>
map <C-P> :cprev<CR>
function! CleverTab()
if strpart( getline('.'), 0, col('.')-1 ) =~ '^\s*$'
return "\<Tab>"
else
return "\<C-N>"
endfunction
inoremap <Tab> <C-R>=CleverTab()<CR>