-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvimrc
165 lines (148 loc) · 6.24 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
" .vimrc
"
" Credits: http://zanshin.net/2011/11/15/using-vim/
" https://gist.github.com/1367558#file_.vimrc
" https://github.com/josephlogik/dotfiles/blob/master/vimrc
" http://got-ravings.blogspot.com/ For statusline material
"
" Dependencies: https://github.com/gmarik/vundle
"
"==============================================================================
" Use Vim settings rather than vi settings (must be first)
"------------------------------------------------------------------------------
set nocompatible
"==============================================================================
" Setup Vundle and plugins
" Refresh with :BundleInstall
"------------------------------------------------------------------------------
if filereadable(expand("~/.vim/bundles.vim"))
source ~/.vim/bundles.vim
endif
"==============================================================================
" Basic Options
"------------------------------------------------------------------------------
let mapleader="\<space>" " Remapped from \"
let maplocalleader="\\"
set encoding=utf-8
set lazyredraw " Don't redraw while executing macros
set laststatus=2 " Always show status bar
set showcmd " display incomplete commands
set hidden
set wildmenu
set wildmode=list:longest,full
set wildignorecase
set scrolloff=1 " At least 1 visible line above/below cursor
set mouse=a
set nojoinspaces " J joins sentences with one space not two
set updatetime=1000 " Faster updates w/ commands waiting for user pause
"==============================================================================
" Statusline
"------------------------------------------------------------------------------
if filereadable(expand('~/.vim/statusline.vim'))
source ~/.vim/statusline.vim
endif
"==============================================================================
" Layout Options
"------------------------------------------------------------------------------
set splitbelow " open splits below rather than above
set splitright " open splits right rather than left
"==============================================================================
" Search Options
"------------------------------------------------------------------------------
set hlsearch " highlight matches
set incsearch " incremental searching
set ignorecase " searches are case insensitive...
set smartcase " unless they contain at least one capital letter
set gdefault " replace all one line by default, use /g for single
"==============================================================================
" Appearance Options
"------------------------------------------------------------------------------
syntax on
set relativenumber
set number
set nowrap " don't wrap lines
set tabstop=2 shiftwidth=2 " a tab is two spaces (or set this to 4)
set shiftround " use even multiples of shiftwidth with >
set expandtab " use spaces, not tabs (optional)
set backspace=indent,eol,start " backspace through everything in insert mode
if exists('+colorcolumn') " Marks the 80th character column
set colorcolumn=80
endif
set textwidth=80
set formatoptions-="t"
colorscheme solarized
set background=dark
set cursorline
" set the cursor to a vertical line in insert mode and a solid block in command mode
if exists('$TMUX')
let &t_SI = "\<Esc>Ptmux;\<Esc>\<Esc>]50;CursorShape=1\x7\<Esc>\\"
let &t_EI = "\<Esc>Ptmux;\<Esc>\<Esc>]50;CursorShape=0\x7\<Esc>\\"
else
let &t_SI = "\<Esc>]50;CursorShape=1\x7"
let &t_EI = "\<Esc>]50;CursorShape=0\x7"
endif
"==============================================================================
" Key Mappings
"------------------------------------------------------------------------------
" Edit/source vimrc
nnoremap <leader>vim :e $MYVIMRC<CR>
nnoremap <leader>sv :so $MYVIMRC<CR>
" Vim&Vigor buffer switching jetpack
nnoremap <leader>l :ls<CR>:b<space>
" Nerdtree shortcut
nnoremap <leader>nt :NERDTreeToggle<CR>
" BDelete to close buffers but not windows
nnoremap <leader>bd :Bdelete<CR>
" FixWhitespace shortcut
nnoremap <leader>w :FixWhitespace<CR>
" Kill search highlighting
nnoremap <silent> <leader>h :noh<CR>
" Sessions
nnoremap <leader>ms :mksession!<CR>
nnoremap <leader>ss :so Session.vim<CR>
nnoremap <leader>gt :GitGutterToggle<CR>
" LaTeX (rubber) macro for compiling
nnoremap <leader>xl :w<CR>:!rubber --pdf --warn all %<CR>
"==============================================================================
" File Type Options
"------------------------------------------------------------------------------
au BufNewFile,BufRead *.ejs setlocal filetype=html
au BufNewFile,BufRead *.ino setlocal filetype=cpp
au BufNewFile,BufRead *.launch setlocal filetype=xml
au Filetype text,tex,latex,gitcommit call SetProseOptions()
" Turn off heavy/annoying things from pymode
" Kind of split on whether or not I even need the package - I basically just
" want the best language syntax highlighting, comment handling, and error
" checking I can get with nothing else
let g:pymode_rope_complete_on_dot = 0
let g:pymode_lint_checkers = ['pyflakes']
let g:pymode_lint_cwindow = 0
let g:org_agenda_files = ['~/org/*.org']
"==============================================================================
" Commands
"------------------------------------------------------------------------------
:command! Numtog :call NumberToggle()
:command! BuffDiff :call FileBuffDiff()
"==============================================================================
" Functions
"------------------------------------------------------------------------------
function! NumberToggle()
if(&relativenumber == 1 || &number == 1)
set norelativenumber
set nonumber
else
set relativenumber
set number
end
endfunc
" Turn on spellcheck and hard wrap for commit messages and latex
function! SetProseOptions()
setlocal spell
setlocal textwidth=80
setlocal formatoptions+=tc
endfunc
" Shows diff between buffer and file on disk
" Nice for when you have buffer changes and pulled in remote changes from git
function! FileBuffDiff()
:w !diff % -
endfunc