-
Notifications
You must be signed in to change notification settings - Fork 1
/
.vimrc
210 lines (178 loc) · 4.23 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
198
199
200
201
202
203
204
205
206
207
208
209
210
" abandon vi
set nocompatible
" make windows use the unix path
if has('win32') || has('win64')
set rtp=$HOME/.vim,$VIM/vimfiles,$VIMRUNTIME,$VIM/vimfiles/after,$HOME/.vim/after
set nowritebackup
endif
" configure vundle
filetype off
set rtp+=~/.vim/bundle/vundle.vim/
call vundle#begin()
" vundle
Plugin 'vundlevim/vundle.vim'
" functional plugins
Plugin 'godlygeek/tabular'
Plugin 'mal/vim-pastemode'
Plugin 'tpope/vim-repeat'
Plugin 'tpope/vim-surround'
" syntax plugins
Plugin 'chaimleib/vim-renpy'
Plugin 'derekwyatt/vim-scala'
Plugin 'elzr/vim-json'
Plugin 'guns/vim-clojure-static'
Plugin 'hashivim/vim-terraform'
Plugin 'kchmck/vim-coffee-script'
Plugin 'mmalecki/vim-node.js'
Plugin 'pangloss/vim-javascript'
Plugin 'tpope/vim-markdown'
Plugin 'vim-ruby/vim-ruby'
Plugin 'zaiste/tmux.vim'
" color schemes
Plugin 'nanotech/jellybeans.vim'
" load plugins
call vundle#end()
filetype plugin indent on
" main options
set autoindent
set background=dark
set backspace=indent,eol,start
set backup
set backupcopy=yes
set backupdir=~/.cache/vim/temp,.,/tmp
set backupskip=/tmp/*,$TMPDIR/*,$TMP/*,$TEMP/*
set clipboard=unnamed
set colorcolumn=80
set cursorline
set directory=~/.cache/vim/swap,.,/tmp
set encoding=utf-8
set expandtab
set fileformats=unix,dos
set formatoptions=qrn1
set gdefault
set hidden
set history=1000
set hlsearch
set ignorecase
set incsearch
set lazyredraw
set list
set listchars=nbsp:¬,tab:>-,trail:·
set nomodeline
set number
set ruler
set scrolloff=3
set shell=sh
set shiftwidth=2
set showcmd
set smartcase
set softtabstop=2
set splitbelow
set splitright
set tabstop=2
set textwidth=72
set ttyfast
set ttymouse=xterm2
set undodir=~/.cache/vim/undo,.,/tmp
set undofile
set wildmenu
set wildmode=list:longest,full
set wrap
" gui options
set gfn=monaco:h12,consolas:h13
set go=iMr
" mousey is here
if has('mouse')
set mouse=a
endif
" pretty colors
syntax on
sil! color jellybeans
" take care of forgetting to use sudo with :w!!
cmap w!! sil exec 'w !sudo tee ' . shellescape(@%, 1) . ' > /dev/null' \| sil e!
" search history
cmap <pageup> <up>
cmap <pagedown> <down>
" bracket navigation
nnoremap <tab> %
vnoremap <tab> %
" avoid shift key
nnoremap ; :
" abort insert mode
inoremap jj <ESC>
" easy tabbing in visual mode
vmap <tab> >
vmap <s-tab> <
vnoremap < <gv
vnoremap > >gv
" time to put up or shut up
inoremap <up> <nop>
inoremap <down> <nop>
inoremap <left> <nop>
inoremap <right> <nop>
nnoremap <up> <nop>
nnoremap <down> <nop>
nnoremap <left> <nop>
nnoremap <right> <nop>
vnoremap <up> <nop>
vnoremap <down> <nop>
vnoremap <left> <nop>
vnoremap <right> <nop>
nnoremap j gj
nnoremap k gk
" take me to your leader
let mapleader = '\'
" deal with pesky windows eol-style
noremap <leader>m mmHmt:%s/<c-v><cr>//ge<cr>
" hide search reslts
nmap <silent> <leader>/ :nohlsearch<cr>
" show whitespace
nmap <silent> <leader>s :set list!<cr>
" nuke whitespace
nmap <silent> <leader>S :%s/\s\+$//<cr>
" retab
nmap <silent> <leader>r :set et<cr>:execute
\ '%s/\v%(^\s*)@<=\t/' . repeat(' ', &tabstop) . '/'<cr>
" inverse retab
nmap <silent> <leader>R :set noet<cr>:execute
\ '%s/\v%(^\s*)@<= {' . &tabstop . '}/\t/'<cr>
" inline sort
vnoremap gsc y:execute "normal gvc" .
\ join(sort(split(getreg('"'), '\s*,\s*')), ', ')<cr>
vnoremap gsv y:execute "normal gvc" .
\ join(sort(split(getreg('"'))), ' ')<cr>
" edit/reload vimrc
nmap <silent> <leader>ve <c-w>s<c-w>j<c-w>L:e $MYVIMRC<cr>
nmap <silent> <leader>vr :so $MYVIMRC<cr>
" easy commenting
func! s:comments(pattern)
exe 'vnoremap <buffer> / ' .
\ ':s/^/' . a:pattern . ' /<cr>:set nohlsearch<cr>gv'
exe 'vnoremap <buffer> ? ' .
\ ':s/^' . a:pattern . '\s\?//<cr>:set nohlsearch<cr>gv'
endf
" default comments
au filetype *
\ call s:comments('#')
" filetype comments
au filetype autohotkey,clojure
\ call s:comments(';')
au filetype c,cpp,go,java,javascript,html,sbt,scala,scss
\ call s:comments('\/\/')
au filetype lua,plsql,sql
\ call s:comments('--')
au filetype vim
\ call s:comments('"')
" filetype tweaks
au filetype c,cpp,go,java,php,python,renpy
\ setl sw=4 sts=4 ts=4
au filetype make
\ setl sw=8 sts=8 ts=8
au filetype go,make
\ setl noet
au filetype markdown,text,yaml
\ setl tw=79
au filetype changelog,gitcommit,markdown,text
\ setl spell
" posix syntax
let is_posix=1