-
Notifications
You must be signed in to change notification settings - Fork 0
/
vimrc
268 lines (209 loc) · 7.69 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
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
execute pathogen#infect()
set nocompatible " be iMproved
filetype off " required!
set rtp+=~/tools/powerline/powerline/bindings/vim
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
let g:vundle_default_git_proto='git'
"let g:ycm_server_keep_logfiles = 1
"let g:ycm_server_log_level = 'debug'
let g:vundle_default_git_proto='git'
"let g:golang_root = '/usr/local/bin'
let g:ycm_confirm_extra_conf = 0
" Vundle
Plugin 'gmarik/Vundle.vim'
" Colorscheme
Plugin 'flazz/vim-colorschemes'
" Git wrapper
Plugin 'tpope/vim-fugitive'
Plugin 'tpope/vim-abolish'
Plugin 'tomasr/molokai'
Plugin 'tpope/vim-repeat'
"
" Fuzzy search
Plugin 'kien/ctrlp.vim'
" Nerdtree
Plugin 'scrooloose/nerdtree'
Bundle 'jistr/vim-nerdtree-tabs'
Plugin 'plasticboy/vim-markdown'
Plugin 'sjl/gundo.vim'
"
" Code completion
Plugin 'Valloric/YouCompleteMe'
Plugin 'rdnetto/YCM-Generator'
" Syntax checking
" Plugin 'scrooloose/syntastic'
Plugin 'altercation/vim-colors-solarized'
Plugin 'Lokaltog/vim-distinguished'
Plugin 'wincent/Command-T'
Plugin 'vim-scripts/vcscommand.vim'
Plugin 'Gundo'
Plugin 'reedes/vim-wordy'
"
" Display powerline
Plugin 'Lokaltog/powerline', {'rtp': 'powerline/bindings/vim/'}
"
" Swap buffers
Plugin 'wesQ3/vim-windowswap'
" Switch to C++ companion files
Plugin 'derekwyatt/vim-fswitch'
" Folding for JSON
Plugin 'elzr/vim-json'
Plugin 'nathanaelkane/vim-indent-guides'
"Plugin 'rkulla/pydiction'
call vundle#end()
"
" ==========================================================
" Basic Settings
" ==========================================================
syntax on " syntax highlighing
filetype on " try to detect filetypes
filetype plugin indent on " enable loading indent file for filetype
set number " Display line numbers
set title " show title in console title bar
set wildmenu " Menu completion in command mode on <Tab>
set wildmode=full " <Tab> cycles between all matching choices.
set guioptions-=m "menu bar
set guioptions-=T "toolbar
set guioptions-=r "scrollbar
set splitbelow
set splitright
" don't bell or blink
set noerrorbells
set vb t_vb=
" Ignore these files when completing
set wildignore+=*.o,*.obj,.git,*.pyc
""" Moving Around/Editing
set cursorline " have a line indicate the cursor location
set ruler " show the cursor position all the time
set nostartofline " Avoid moving cursor to BOL when jumping around
set virtualedit=block " Let cursor move past the last char in <C-v> mode
set scrolloff=5 " Keep 5 context lines above and below the cursor
set backspace=2 " Allow backspacing over autoindent, EOL, and BOL
set showmatch " Briefly jump to a paren once it's balanced
set wrap " Wrap text
set linebreak " don't wrap textin the middle of a word
set autoindent " always set autoindenting on
set smartindent " use smart indent if there is no indent file
set tabstop=2 " <tab> inserts 4 spaces
set shiftwidth=2 " an indent level is 2 spaces wide.
set softtabstop=2 " <BS> over an autoindent deletes both spaces.
set expandtab " Use spaces, not tabs, for autoindent/tab key.
set shiftround " rounds indent to a multiple of shiftwidth
set formatoptions=tcroql " Setting text and comment formatting to auto
set textwidth=120 " Lines are automatically wrapped after 120 columns
set linespace=3 " The spacing between lines is a little roomier
"""" Reading/Writing
set autowrite " Stop complaining about unsaved buffers
set autowriteall " I'm serious...
set modeline " Allow vim options to be embedded in files;
set modelines=3 " they must be within the first or last 5 lines.
"""" Messages, Info, Status
set ls=2 " allways show status line
set vb t_vb= " Disable all bells. I hate ringing/flashing.
set showcmd " Show incomplete normal mode commands as I type.
set report=0 " : commands always print changed line count.
set shortmess+=a " Use [+]/[RO]/[w] for modified/readonly/written.
set ruler " Show some info, even without statuslines.
set laststatus=2 " Always show statusline, even if only 1 window.
""" Searching and Patterns
set ignorecase " Default to using case insensitive searches,
set smartcase " unless uppercase letters are used in the regex.
set hlsearch " Highlight searches by default.
set incsearch " Incrementally search while typing a /regex
set gdefault " Replace all instances by default
""" copy/paste
set clipboard+=unnamed " use the clipboards of vim and win
set paste " Paste from a windows or from vim
" Left arrow at beginning of line should go to end of previous line
" and same for right arrow...
set whichwrap+=<,>
:let mapleader=","
" Cycle through open buffers with Control + Spacebar
map <C-space> :bn <CR>
map <C-M-space> :bp <CR>
" I bet 90% of vim users have the following two lines in their .vimrc...
syntax on
let g:solarized_termtrans=1
let g:solarized_termcolors=256
colorscheme molokai
"auto reload vimrc once changed
" Don't create swapfiles
" set noswapfile
" Allow for undo even after closing and re-opening a file
if exists("+undofile")
" undofile - This allows you to use undos after exiting and restarting
" This, like swap and backups, uses .vim-undo first, then ~/.vim/undo
" :help undo-persistence
" This is only present in 7.3+
if isdirectory($HOME . '/.vim/undo') == 0
:silent !mkdir -p ~/.vim/undo > /dev/null 2>&1
endif
set undodir=./.vim-undo//
set undodir+=~/.vim/undo//
set undofile
endif
" Make diffs *really* obvious
hi DiffText gui=underline guibg=red guifg=black
" syntastic: show errors from all linters at once
let g:syntastic_aggregate_errors = 1
" Set CtrlP to search by filename rather than path
let g:ctrlp_by_filename = 0
set guifont=Inconsolata\ for\ Powerline:h15
let g:Powerline_symbols = 'fancy'
set encoding=utf-8
set t_Co=256
set fillchars+=stl:\ ,stlnc:\
set term=xterm-256color
set termencoding=utf-8
if has("gui_running")
let s:uname = system("uname")
if s:uname == "Darwin\n"
set guifont=Inconsolata\ for\ Powerline:h15
endif
endif
""" SHORTCUTS ""
" Save the shift
nnoremap ; :
" Write all files
imap ww <Esc>:wa<CR> " write all files and command mode
" When creating a new file, create the directories if needed
"command -nargs=1 E execute('set wildmode=longest:full,full! silent! !mkdir -p "$(dirname "<args>")"') <Bar> e <args>
" Fast Esc mode
imap jj <Esc>
imap kk <Esc>
" Python 'self'
iabbrev adn and
let g:pydiction_location = '~/.vim/bundle/pydiction/complete-dict'
" No arrows!
map <up> <nop>
map <down> <nop>
map <left> <nop>
map <right> <nop>
" Jumps to the next row in the editor (much more natural):
nnoremap j gj
nnoremap k gk
" Easy window navigation
map <C-h> <C-w>h
map <C-j> <C-w>j
map <C-k> <C-w>k
map <C-l> <C-w>l
" Use Q for formatting the current paragraph (or selection)
vmap Q gq
nmap Q gqap
" clang-format shortcut
map <C-I> :pyf /Users/antoine/.vim/clang-format.py<cr>
imap <C-I> <c-o>:pyf /Users/antoine/.vim/clang-format.py<cr>
" NERDTree Ignore
let NERDTreeIgnore = ['\.pyc$', '__$[[dir]]', '__init__.py']
" Disable highlight of search
nnoremap <space> :noh<CR><CR>
" Run programs
au BufEnter,BufNew *.cpp map <F8> :!clang++ --std=c++14 % && ./a.out <CR>
au BufEnter,BufNew *.py map <F8> :!python3 % <CR>
" to do sudo after
cmap w!! w !sudo tee % >/dev/null
vmap <C-c> "+yi
vmap <C-x> "+c
vmap <C-v> c<ESC>"+p
imap <C-v> <C-r><C-o>+