-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvimrc
More file actions
263 lines (231 loc) · 6.13 KB
/
vimrc
File metadata and controls
263 lines (231 loc) · 6.13 KB
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
set nocompatible
" Sets how many lines of history VIM has to remember
set history=1000
set undolevels=1000
" Set to auto read when a file is changed from the outside
set autoread
" Allow backspacing over everything in insert mode
set backspace=indent,eol,start
" Set to show line number
set number
" Set to show the cursor position all the time
set ruler
" Display incomplete commands
set showcmd
"windows Display the mode you're in
set showmode
" Set show matching parenthesis
set showmatch
" Set to highlighting the last used search pattern.
set hlsearch
" Set to do incremental searching
set incsearch
" Case-insensitive search
set ignorecase
" But case-sensitive if expression contains a capital letter
set smartcase
" Handle multiple buffers better.
set hidden
" Set autoindent
set autoindent
" Copy previous indentation
set copyindent
" Set the terminal's title
set title
" Don't make a backup before overwriting a file.
set nobackup
" And again.
set nowritebackup
" Don't make swap file
set noswapfile
" No word wrap
set nowrap
" Add a bit extra margin to the left
set foldcolumn=1
" Height of the command bar
set cmdheight=2
" Don't redraw while executing macros (good performance config)
set lazyredraw
" Set utf8 as standard encoding and en_US as the standard language
set encoding=utf8
" Prevents some security exploits
set modelines=0
" Set N lines of context around the cursor, at bottom-side
set scrolloff=5
" Same as before but left-side
set sidescrolloff=15
set sidescroll=1
" Enhaced command line completion
set wildmenu
" Complete files like a shell
set wildmode=list:longest,full
" Ignore when expand
set wildignore=*.swp,*.bak,*.o,*.obj
" Always show status line
set laststatus=2
" Highlight current line
set cursorline
" Faster esc in visual/insert mode
set ttimeout
set ttimeoutlen=10
" Longer mapping waiting time
set timeout
set timeoutlen=3000
" Use the same symbols as TextMate for tabstops and EOLs
set listchars=tab:>\ ,trail:.,nbsp:.,eol:¬
" No sound bell, flash screen
set visualbell
" Fast terminal connection
set ttyfast
" Global tab width.
set tabstop=4
" And again, related.
set softtabstop=4
" And again, related.
set shiftwidth=4
" Use spaces instead of tabs
set expandtab
" Max line width
set textwidth=80
" Max number of tab pages
set tabpagemax=100
" Enable folding
set foldenable
" Start with all fold closed
set foldlevelstart=0
" Max nested level (not so deep)
set foldnestmax=2
" Use marker as fold method
set foldmethod=marker
" Fix terminal problems
if !has('gui_running')
set t_RV=
set t_Co=256 " Explicitly tell vim that the terminal supports 256 colors
endif
" GUI config
if has('gui_running')
set guioptions-=m
set guioptions-=T
set guioptions-=r
let g:gtk_nocache=[0x00000000, 0xfc00ffff, 0xf8000001, 0x78000001]
set guifont=FuraCode\ Nerd\ Font\ 14
endif
" Remap leader
let mapleader=","
let maplocalleader=","
" Make Y behave consistently with D and C
nnoremap Y y$
" Shortcuts
"
" Force file write
nnoremap <leader>w :w!<cr>
" Quit all
nnoremap <leader>q :qall<cr>
" Toggle listchars option
nnoremap <leader>l :set list!<cr>
" Turn off highlighted matches
nnoremap <leader><space> :nohls<cr>
" Simple ad blank line (next)
nnoremap <leader>o o<esc>k
" Simple add blank line (prev)
nnoremap <leader>O O<esc>j
" Access vimrc
nnoremap <silent> <leader>erc :tabedit $MYVIMRC<cr>
nnoremap <silent> <leader>egrc :tabedit $MYGVIMRC<cr>
nnoremap <silent> <leader>src :source $MYVIMRC<cr>
nnoremap <silent> <leader>sgrc :source $MYGVIMRC<cr>
" Opening files located in the same directory as the current file
cnoremap %% <C-R>=fnameescape(expand('%:h')).'/'<cr>
map <leader>ew :e %%
map <leader>es :sp %%
map <leader>ev :vsp %%
map <leader>et :tabe %%
" Upper\Lower case mapping
nnoremap <C-u> g~iwe
inoremap <C-u> <esc>g~iwea
" Tabs mappings
noremap <leader>tt :tabnew<cr>
noremap <leader>te :tabedit
noremap <leader>tc :tabclose<cr>
noremap <leader>to :tabonly<cr>
noremap <leader>tn :tabnext<cr>
noremap <leader>tp :tabprevious<cr>
noremap <leader>tf :tabfirst<cr>
noremap <leader>tl :tablast<cr>
noremap <leader>tm :tabmove
" Windows mappings
noremap <C-h> <C-w>h
noremap <C-j> <C-w>j
noremap <C-k> <C-w>k
noremap <C-l> <C-w>l
" No Arrow Keys!
nnoremap <up> <nop>
nnoremap <down> <nop>
nnoremap <left> <nop>
nnoremap <right> <nop>
inoremap <up> <nop>
inoremap <down> <nop>
inoremap <left> <nop>
inoremap <right> <nop>
" No stupid help
nnoremap <F1> <nop>
inoremap <F1> <nop>
vnoremap <F1> <nop>
" Move by screen line instead of file line
nnoremap j gj
nnoremap k gk
" Visual shifting does not exit visual mode
vnoremap < <gv
vnoremap > >gv
" Run an external command with only single bang
nnoremap ! :!
augroup FixBeforeWrite
autocmd!
autocmd BufWritePre * call RemoveTrailingWhitespaces()
augroup END
" Disable filetpye, this is important to do *before* plugins installation
filetype off
call plug#begin('~/.vim/plugged')
Plug 'dracula/vim', { 'as': 'dracula' }
Plug 'tpope/vim-unimpaired'
Plug 'tpope/vim-repeat'
Plug 'tpope/vim-commentary'
Plug 'tpope/vim-endwise'
Plug 'tpope/vim-surround'
Plug 'mhinz/vim-startify'
Plug 'mhinz/vim-signify'
let g:signify_vcs_list=[ 'git', 'hg', 'svn' ]
let g:signify_realtime = 0
Plug 'justinmk/vim-gtfo'
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
Plug 'junegunn/fzf.vim'
Plug 'junegunn/vim-peekaboo'
let g:peekaboo_window = 'vertical botright 50new'
let g:peekaboo_delay = 500
Plug 'junegunn/limelight.vim'
Plug 'junegunn/goyo.vim'
Plug 'bling/vim-airline'
let g:airline_powerline_fonts = 1
Plug 'vim-airline/vim-airline-themes'
Plug 'ryanoasis/vim-devicons'
call plug#end()
" Enable syntax
syntax on
" Enable indentation, this is important to do *after* 'vundle#end()'
filetype plugin indent on
" Custom indentation
if has('autocmd')
autocmd filetype ruby set tabstop=2 softtabstop=2 shiftwidth=2
autocmd filetype javascript set tabstop=2 softtabstop=2 shiftwidth=2
autocmd filetype json set tabstop=2 softtabstop=2 shiftwidth=2
endif
" Set color theme
color dracula
" Custom function
function! RemoveTrailingWhitespaces()
let l:save_cursor = getpos('.')
silent! execute ':%s/\s\+$//'
call setpos('.', l:save_cursor)
endfunction
" FZF shortcut
nnoremap <C-p> :<C-u>FZF<CR>