-
Notifications
You must be signed in to change notification settings - Fork 0
/
.vimrc
256 lines (183 loc) · 5.12 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
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Creator:
" Cristian A. Cardellino
" https://crscardellino.github.io
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" =============
" Preconditions
" =============
" use vim settings, not vi settings (needed)
set nocompatible
" =========================
" vim-plug (plugin manager)
" =========================
let data_dir = has('nvim') ? stdpath('data') . '/site' : '~/.vim'
if empty(glob(data_dir . '/autoload/plug.vim'))
silent execute '!curl -fLo '.data_dir.'/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim'
autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
endif
" vim-plug start
call plug#begin()
" personal plugins
Plug 'chriskempson/base16-vim'
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
" vim-plug end
call plug#end()
" =======
" General
" =======
" keep 500 lines of command line history
set history=100
" use 100 levels of undo
set undolevels=100
" set endline to unix-style
set ff=unix
" change the terminal's title
set title
" <leader> and <localleader>
let mapleader = ","
let maplocalleader = "\\"
" capital "Q" to quit all
command Q :qall
" capital "W" to write all
command W :wall
" capital "WQ" to write and quit all
command WQ :wall | :qall
" "Vimrc" to edit the .vimrc file
command Vimrc :tabe ~/.vimrc
" =================
" Buffers & Windows
" =================
" don't force close of buffers
set hidden
" Buffer switching
nnoremap <leader>n :bn<cr>
nnoremap <leader>p :bp<cr>
" Tab switching
nnoremap <localleader>n :tabnext<cr>
nnoremap <localleader>p :tabprevious<cr>
" Resize
nnoremap <localleader>[ :vertical resize -5<cr>
nnoremap <localleader>] :vertical resize +5<cr>
nnoremap <localleader>{ :res -5<cr>
nnoremap <localleader>} :res +5<cr>
" ==============
" Edition & Text
" ==============
" syntax highlighting
syntax on
" word wrap
set textwidth=0
" highlight column 80
set colorcolumn=80
" insert newline character
nmap <c-o> O<esc>j
" insert newline
nnoremap <cr> a<cr><esc>k$
" allow backspacing over everything in insert mode
set backspace=indent,eol,start
" size of a hard tabstop
set tabstop=4
" size of an "indent"
set shiftwidth=4
" a combination of spaces and tabs are used to simulate tab stops at a width
" other than the (hard)tabstop
set softtabstop=4
" make "tab" insert indents instead of tabs at the beginning of a line
set smarttab
" always uses spaces instead of tab characters
set expandtab
" don't wrap lines
set nowrap
" always set autoindenting on
set autoindent
" copy the previous indentation on autoindenting
set copyindent
" toggle pastemode
set pastetoggle=<F2>
" set new vertical splits to the right and horizontal to below
set splitright
set splitbelow
" set different tabspaces for some files
autocmd Filetype html setlocal ts=2 sts=2 sw=2
autocmd Filetype tex setlocal ts=2 sts=2 sw=2
" ===================
" Files & Directories
" ===================
" change the dir
set autochdir
" Remove temp files created by vim
set nobackup
set noundofile
" set to auto read when a file is changed from the outside
set autoread
" set utf8 as standard encoding and en_US as the standard language
set encoding=utf8
" Use Unix as the standard file type
set ffs=unix,dos,mac
" Ignore this files when using wildcards
set wildignore=*.swp,*.bak,*.pyc,*.class,.git/,tmp/
" set default filetypes
let g:tex_flavor = "latex"
" =========
" Interface
" =========
" show the cursor position all the time
set ruler
" display incomplete commands
set showcmd
" show line number
set number
set background=dark
let base16colorspace=256
colorscheme base16-twilight
let g:airline_theme='base16'
hi Normal guibg=NONE ctermbg=NONE
" show matching brackets when text indicator is over them
set showmatch
" remove trailing whitespaces with <F5>
nnoremap <silent> <F5> :let _s=@/<Bar>:%s/\s\+$//e<Bar>:let @/=_s<Bar>:nohl<CR>
" map \w to wrapping lines
nnoremap <localleader>w :set wrap linebreak nolist<cr>
" ======
" Moving
" ======
" treat long lines as break lines (useful when moving around in them)
map j gj
map k gk
" Smart way to move between windows
map <c-j> <c-w>j:cd %:p:h<cr>:<cr>
map <c-k> <c-w>k:cd %:p:h<cr>:<cr>
map <c-h> <c-w>h:cd %:p:h<cr>:<cr>
map <c-l> <c-w>l:cd %:p:h<cr>:<cr>
" Tab to switch windows
map <tab> <c-w>w:cd %:p:h<cr>:<cr>
" continue to next and previous line when moving
set whichwrap+=<,>,h,l,[,]
" ======
" Search
" ======
" do incremental searching
set incsearch
" highlight search results
set hlsearch
" ignore case while searching
set ignorecase
" case-sensitive is patter is not all-lowercase
set smartcase
" =======
" Plugins
" =======
" Airline
set laststatus=2
set ttimeoutlen=50
let g:airline#extensions#tabline#enabled = 1
let g:airline#extensions#branch#enabled = 1
let g:airline#extensions#branch#empty_message = ''
let g:airline#extensions#syntastic#enabled = 1
let g:airline_powerline_fonts = 1
" base16 - needed for true color support, deactivate
" in case of incorrect colors.
" Check here: https://github.com/chriskempson/base16-vim#troubleshooting
set termguicolors