-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvimrc
197 lines (169 loc) · 6.2 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
" Directives for use with: https://github.com/bronson/vim-update-bundles
" https://raw.github.com/bronson/vim-update-bundles/master/vim-update-bundles
" Bundle: https://github.com/ervandew/screen.git
" Bundle: https://github.com/vim-perl/vim-perl.git
" Bundle: https://github.com/scrooloose/nerdtree.git
" Bundle: https://github.com/tpope/vim-fugitive.git
" Bundle: https://github.com/tpope/vim-markdown.git
" Bundle: https://github.com/tpope/vim-speeddating.git
" Bundle: https://github.com/tpope/vim-surround.git
" Bundle: https://github.com/tpope/vim-commentary.git
" Bundle: https://github.com/tomtom/tlib_vim.git
" Bundle: https://github.com/MarcWeber/vim-addon-mw-utils.git
" Bundle: Align
" Bundle: https://github.com/kien/ctrlp.vim.git
" Bundle: Railscasts-Theme-GUIand256color
" Bundle: https://github.com/altercation/vim-colors-solarized.git
" Bundle: https://github.com/bling/vim-airline.git
" Bundle: https://github.com/rodjek/vim-puppet.git
" Bundle: https://github.com/krisajenkins/vim-pipe.git
" Bundle: https://github.com/reedes/vim-pencil.git
runtime bundle/vim-pathogen/autoload/pathogen.vim
" Bundle: tpope/vim-pathogen ed01fca95
call pathogen#infect()
set nocompatible
" allow backspacing over everything in insert mode
set backspace=indent,eol,start
set autoindent " always set autoindenting on
set history=50 " keep 50 lines of command line history
set ruler " show the cursor position all the time
set showcmd " display incomplete commands
set incsearch " do incremental searching
set background=dark
set showmatch
set ignorecase
set smartcase
set hidden " don't tell me to save a buffer before when I
set smartindent
set autoindent
set expandtab
set laststatus=2
set fileencoding=utf-8
set encoding=utf-8
let g:showmarks_enable=0 " Disable showmarks by default.
" Switch syntax highlighting on, when the terminal has colors
" Also switch on highlighting the last used search pattern.
if &t_Co > 2 || has("gui_running")
syntax on
set hlsearch
endif
" set background=dark
" colorscheme railscasts
let g:solarized_termcolors=256
syntax enable
set background=light
colorscheme solarized
set t_Co=256
" Theme setting:
if has("gui_running")
set guifont=Monospace\ 9
set guioptions=aegim
endif
" Key mappings:
map #2 :s/\([A-Z]\)\([A-Z][A-Z]*\)/\1\L\2/g<CR>
map #3 :Tlist<CR>
map #4 :ShowMarksToggle<CR>
" Number truncation:
map <silent> ,,t :. rubydo $_.gsub!(/(\d+\.\d+)/) { sprintf("%.*f", 2, $1.to_f) } <CR>
map <silent> ,,td :rubydo $_.gsub!(/(\d+\.\d+)/) { sprintf("%.*f", 2, $1.to_f) } <CR>
" Switch off the arrow keys :-)
" :nnoremap <Up> <Nop>
" :nnoremap <Down> <Nop>
" :nnoremap <Left> <Nop>
" :nnoremap <Right> <Nop>
" Bracketed paste mode
" From: http://stackoverflow.com/questions/5585129/pasting-code-into-terminal-window-into-vim-on-mac-os-x
if &term =~ "xterm.*"
let &t_ti = &t_ti . "\e[?2004h"
let &t_te = "\e[?2004l" . &t_te
function XTermPasteBegin(ret)
set pastetoggle=<Esc>[201~
set paste
return a:ret
endfunction
map <expr> <Esc>[200~ XTermPasteBegin("i")
imap <expr> <Esc>[200~ XTermPasteBegin("")
endif
if has("autocmd")
filetype plugin indent on
" Filetype overrides.
"see header files as 'c' header, instead of cpp.
au BufRead,BufNewFile *.h setfiletype c
autocmd Filetype c setlocal shiftwidth=4 shiftround
"and make sure html files shiftwdith is 2.
autocmd FileType *html setlocal shiftwidth=2
autocmd FileType *xml setlocal shiftwidth=2
autocmd FileType matlab setlocal shiftwidth=2
autocmd FileType ruby setlocal shiftwidth=2
autocmd FileType perl setlocal shiftwidth=4 tabstop=4 softtabstop=4
au! BufRead,BufNewFile *.otl setfiletype vo_base
au! BufRead,BufNewFile *.oln setfiletype xoutliner
au! BufRead,BufNewFile *.gp setfiletype gnuplot
autocmd BufRead,BufNewFile *.py set ai
" When editing a file, always jump to the last known cursor position.
" Don't do it when the position is invalid or when inside an event
" handler (happens when dropping a file on gvim).
autocmd BufReadPost *
\ if line("'\"") > 0 && line("'\"") <= line("$") |
\ exe "normal g`\"" |
\ endif
endif " has("autocmd")
if has("autocmd") && exists("+omnifunc")
autocmd Filetype *
\ if &omnifunc == "" |
\ setlocal omnifunc=syntaxcomplete#Complete |
\ endif
endif
cnoremap %% <C-R>=expand('%:h').'/'<cr>
map <leader>e :edit %%
map <leader>v :view %%
set winwidth=84
" We have to have a winheight bigger than we want to set winminheight. But if
" we set winheight to be huge before winminheight, the winminheight set will
" fail.
set winheight=5
set winminheight=5
set winheight=999
set cursorline
let mapleader=","
nnoremap <leader><leader> <c-^>
set scrolloff=3
" Store temporary files in a central spot
set backupdir=~/.vim-tmp,~/.tmp,~/tmp,/var/tmp,/tmp
set directory=~/.vim-tmp,~/.tmp,~/tmp,/var/tmp,/tmp
if has("vms")
set nobackup " do not keep a backup file, use versions instead
else
set backup " keep a backup file
endif
" GRB: clear the search buffer when hitting return
:nnoremap <CR> :nohlsearch<cr>
" GRB: use emacs-style tab completion when selecting files, etc
set wildmode=longest,list
" GRB: Put useful info in status line
:set statusline=%<%f\ (%{&ft})\ %-4(%m%)%=%-19(%3l,%02c%03V%)
:hi User1 term=inverse,bold cterm=inverse,bold ctermfg=red
" Remap the tab key to do autocompletion or indentation depending on the
" context (from http://www.vim.org/tips/tip.php?tip_id=102)
function! InsertTabWrapper()
let col = col('.') - 1
if !col || getline('.')[col - 1] !~ '\k'
return "\<tab>"
else
return "\<c-p>"
endif
endfunction
inoremap <tab> <c-r>=InsertTabWrapper()<cr>
inoremap <s-tab> <c-n>
map <leader>F :CommandTFlush<cr>\|:CommandT %%<cr>
map <leader>f :CommandTFlush<cr>\|:CommandT<cr>
map <leader>gt :CommandTFlush<cr>\|:CommandT tests<cr>
" Don't use Ex mode, use Q for formatting
map Q gq
" let g:Powerline_symbols='fancy'
let g:airline_powerline_fonts = 1
" CtrlP settings - see: http://dougblack.io/words/a-good-vimrc.html
let g:ctrlp_match_window = 'bottom,order:ttb'
let g:ctrlp_switch_buffer = 0
let g:ctrlp_working_path_mode = 0
let g:ctrlp_user_command = 'ag %s -l --nocolor --hidden -g ""'