forked from holman/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvimrc.symlink
280 lines (227 loc) · 7.57 KB
/
vimrc.symlink
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
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
filetype off
let VundleFound = 1
let VundleReadme = expand('~/.vim/bundle/vundle/README.md')
if !filereadable(VundleReadme)
echo 'Installing Vundle'
echo ''
silent !mkdir -p ~/.vim/bundle
silent !git clone https://github.com/gmarik/vundle ~/.vim/bundle/vundle
let VundleFound = 0
endif
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()
Bundle 'gmarik/vundle'
"Bundle 'kien/ctrlp.vim'
Bundle 'kien/rainbow_parentheses.vim'
Bundle 'scrooloose/nerdcommenter'
"Bundle 'scrooloose/nerdtree'
Bundle 'scrooloose/syntastic'
"Bundle 'mileszs/ack.vim'
"Bundle 'tpope/vim-surround'
"Bundle 'tpope/vim-repeat'
"Bundle 'tpope/vim-endwise'
"Bundle 'tpope/vim-markdown'
Bundle 'tpope/vim-fugitive'
"Bundle 'tpope/vim-rsi'
Bundle 'altercation/vim-colors-solarized'
"Bundle 'tomasr/molokai'
Bundle 'Lokaltog/vim-powerline'
"Bundle 'Lokaltog/vim-easymotion'
Bundle 'majutsushi/tagbar'
"Bundle 'ervandew/supertab'
"Bundle 'SirVer/ultisnips'
"Bundle 'honza/vim-snippets'
"Bundle 'Shougo/neocomplcache' "old
"Bundle 'Shougo/neocomplete.vim' "new
"Bundle 'Valloric/YouCompleteMe'
if !VundleFound
echo 'Installing Bundles...'
echo ''
:BundleInstall
endif
syntax on
filetype plugin indent on
set nocompatible
set noswapfile
set shortmess=atI
set backup
set backupdir=~/.tmp,~/,.
set directory=~/.tmp,~/,.
set history=500
" In many terminal emulators the mouse works just fine, thus enable it.
if has('mouse')
set mouse=a
endif
set tags=./tags;,~/.vimtags
set clipboard=unnamed
cmap w!! w !sudo tee % >/dev/null
set spelllang=en_gb
map ,s z=
" ----------------------------------------------------------------------------
" Text Formatting
" ----------------------------------------------------------------------------
set autoindent " automatic indent new lines
set smartindent " be smart about it
inoremap # X<BS>#
set nowrap " do not wrap lines
set softtabstop=4
set shiftwidth=4
set tabstop=4
set expandtab " expand tabs to spaces
set nosmarttab " fuck tabs
set formatoptions+=n " support for numbered/bullet lists
set textwidth=72 " wrap at 80 chars by default
set colorcolumn=72
set virtualedit=block " allow virtual edit in visual block ..
" ----------------------------------------------------------------------------
" Remapping
" ----------------------------------------------------------------------------
" lead with ,
let mapleader = ","
" exit to normal mode with 'jj'
inoremap jj <ESC>
inoremap kk <ESC>
inoremap jk <ESC>
inoremap Jk <ESC>
cnoremap jk <ESC>
" set undo point at C-U
inoremap <C-U> <C-G>u<C-U>
nnoremap 0 ^
nnoremap ^ 0
nnoremap ; :
nnoremap <leader>Q :qall!<CR>
nnoremap <leader>q :q<CR>
nnoremap <leader>w :w<CR>
nnoremap <leader>W :silent w !sudo tee % > /dev/null<CR>
nnoremap <leader>x :x<CR>
nnoremap <leader>e :e<Space>
nnoremap <leader>m :w<CR>:make<CR>
" reflow paragraph with Q in normal and visual mode
nnoremap Q gqap
vnoremap Q gq
" sane movement with wrap turned on
nnoremap j gj
nnoremap k gk
vnoremap j gj
vnoremap k gk
nnoremap <Down> gj
nnoremap <Up> gk
vnoremap <Down> gj
vnoremap <Up> gk
inoremap <Down> <C-o>gj
inoremap <Up> <C-o>gk
"" Space toggles folds
"nnoremap <Space> za
"vnoremap <Space> za
"" readline mappings
"inoremap <C-a> <Home>
"inoremap <C-e> <End>
"inoremap <C-f> <Right>
"inoremap <C-b> <Left>
"inoremap <C-n> <Down>
"inoremap <C-p> <Up>
" key tweaks
inoremap <nul> _
inoremap <C-Space> _
nnoremap <silent> <leader>of :FSHere<CR>
nnoremap <silent> <leader>a :Ack<Space>
nnoremap <silent> <leader>gd :Gdiff<CR>
"" Use very magic search
"cnoremap s/ s/\v
"nnoremap / /\v
"nnoremap ? ?\v
"vnoremap / /\v
"vnoremap ? ?\v
" ----------------------------------------------------------------------------
" Window
" ----------------------------------------------------------------------------
nnoremap <C-h> <C-W>h
nnoremap <C-j> <C-W>j
nnoremap <C-k> <C-W>k
nnoremap <C-l> <C-W>l
" ----------------------------------------------------------------------------
" UI
" ----------------------------------------------------------------------------
set ruler " show the cursor position all the time
set noshowcmd " don't display incomplete commands
set noshowmode
set nolazyredraw " turn off lazy redraw
set number " line numbers
set relativenumber
set wildmenu " turn on wild menu
set wildmode=list:longest,full
set ch=2 " command line height
set backspace=2 " allow backspacing over everything in insert mode
set whichwrap+=<,>,h,l,[,] " backspace and cursor keys wrap to
set shortmess=filtIoOA " shorten messages
set report=0 " tell us about changes
set nostartofline " don't jump to the start of line when scrolling
set scrolloff=3
if has("autocmd")
" Put these in an autocmd group, so that we can delete them easily.
augroup vimrcEx
au!
" 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).
" Also don't do it when the mark is in the first line, that is the default
" position when opening a file.
autocmd BufReadPost *
\ if line("'\"") > 1 && line("'\"") <= line("$") |
\ exe "normal! g`\"" |
\ endif
augroup END
endif " has("autocmd")
" ----------------------------------------------------------------------------
" Visual Cues
" ----------------------------------------------------------------------------
set showmatch " brackets/braces that is
set mat=5 " duration to show matching brace (1/10 sec)
set incsearch " do incremental searching
set hlsearch
set laststatus=2 " always show the status line
set ignorecase " ignore case when searching
set smartcase
set visualbell " shut the fuck up
" ---------------------------------------------------------------------------
" Strip all trailing whitespace in file
" ---------------------------------------------------------------------------
function! StripWhitespace ()
exec ':%s/ \+$//gc'
endfunction
" map ,s :call StripWhitespace ()<CR>
" ---------------------------------------------------------------------------
" C settings
" ---------------------------------------------------------------------------
set cino+=(0
if !exists("autocommands_loaded")
let autocommands_loaded = 1
au BufNewFile *.h call s:InsertCHeader()
endif
function! s:InsertCHeader()
let fname = '_' . expand('%:t')
let fname = toupper(fname)
let fname = substitute(fname, '\.', '_', 'g')
call setline(line('.'), "#ifndef " . fname)
call append(line('$'), "#define " . fname)
call append(line('$'), "")
call append(line('$'), "")
call append(line('$'), "")
call append(line('$'), "#endif")
normal GGkk
endfunction
" ---------------------------------------------------------------------------
" Plugins
" ---------------------------------------------------------------------------
au VimEnter * RainbowParenthesesToggle
au Syntax * RainbowParenthesesLoadRound
au Syntax * RainbowParenthesesLoadSquare
au Syntax * RainbowParenthesesLoadBraces
let g:tagbar_ctags_bin="/usr/local/bin/ctags"
let g:UltiSnipsEditSplit="vertical"
let g:UltiSnipsListSnippets="<c-l>"
let g:UltiSnipsSnippetDirectories = ['~/.vim/UltiSnips', 'UltiSnips']
let g:UltiSnipsExpandTrigger="<tab>"
let g:UltiSnipsJumpForwardTrigger="<tab>"
let g:UltiSnipsJumpBackwardTrigger="<s-tab>"
nnoremap <leader>se :UltiSnipsEdit<CR>