forked from davidclin/vim
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.vimrc
319 lines (276 loc) · 10.8 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
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
" ##########################################################
" ########## David Lin's .vimrc File ##########
" ########## https://github.com/davidclin/vim.git ##########
" ##########################################################
"
" ############################
" ########## Vundle ##########
" ############################
"
" Vundle is an easy to use and powerful VIM plugin manager.
"
" Step 1. Download
"
" (for Linux)
" git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim
"
" (for Windows)
" git clone https://github.com/VundleVim/Vundle.vim.git ./vimfiles/bundle/Vundle.vim
"
" Assumes Git is installed in c:\Users\<username> directory and this path is your $HOME.
"
" Step 2. Add Plugins
"
" Add your favorite plugins under the 'Plugins' section below
"
" Step 3. Install Plugins
"
" cd vim
" cp .vimrm ~/.vimrc
" vim
" :PluginList
" :PluginInstall
" :PluginUpdate
"
" Plugin Commands Summary
" :PluginList - lists configured plugins
" :PluginInstall - installs plugins; append `!` to update or just :PluginUpdate
" :PluginSearch foo - searches for foo; append `!` to refresh local cache
" :PluginClean - confirms removal of unused plugins; append `!` to auto-approve removal
"
" See :h vundle for more details or wiki for FAQ
"
"
" #####################################
" ########## Custom Mappings ##########
" #####################################
"
"|----------------------------------------+---------|
"| Description | Command |
"|----------------------------------------+---------|
"| Next buffer | ;; |
"| Previous Buffer | aa |
"| Equally sized split windows | <F2> |
"| Expand present vert split window | <F3> |
"| Expand present horizontal spit windows | <F4> |
"| Remove all trailing whitespaces | <F5> |
"| Change split window | Ctrl-j |
"| | Ctrl-k |
"| | Ctrl-h |
"| | Ctrl-l |
"| Start NERDTree | Ctrl-n |
"| Close NERDTree | q |
"| NERDTree menu | m |
"|----------------------------------------+---------|
"
"
" #########################################
" ########## Useful VIM Commands ##########
" #########################################
"
" |------------------------+-----------------------------------|
" | Description | Command |
" |------------------------+-----------------------------------|
" | Open web page from vim | gx |
" |------------------------+-----------------------------------|
" | Table Mode | <leader>tm |
" | | use single pipe to create cell(s) |
" | | use double pipe to create line |
" |------------------------+-----------------------------------|
" | Easy Motion | <leader><leader>w |
" | | <leader><leader>b |
" |------------------------+-----------------------------------|
" | Execute shell cmd | :!<command> |
" |------------------------+-----------------------------------|
" | List buffers | :ls |
" | Open buffer | :b<#> |
" |------------------------+-----------------------------------|
" | Sustitution | :s/match/new_string/[g|c|i] |
" | | g global |
" | | c confirm |
" | | i case insensitive |
" | | I case sensitive |
" |------------------------+-----------------------------------|
" | Change inner word | ciw |
" | Change inner quotes | ci" |
" | Change inner paragraph | cip |
" | Change inner tag | cit |
" | Change as sentence | cas |
" | | |
" | | Other verbs: |
" | | delete (d) |
" | | indent (>) |
" | | visually select (v) |
" | | yank (y) |
" |------------------------+-----------------------------------|
" | Search for string | / search forward |
" | | ? search backward |
" |------------------------+-----------------------------------|
" | Search for string in | :find <string> |
" | NerdTree | |
" |------------------------+-----------------------------------|
" | Invert line order | :g/^/m0 |
" |------------------------+-----------------------------------|
"
"
" ###########################################
" ########## Useful Linux Commands ##########
" ###########################################
"
" Add the following line to Ubuntu "Startup Applications"
" to remap CapsLock to Control Key:
"
" setxkbmap -option 'caps:ctrl_modifier'
"
"
" #################################
" ########## Useful Tips ##########
" #################################
"
" This is where you can set the VIM default directory path:
" cd /home/user/my/work/dir (for Linux)
" cd c:\Users\<username> (for Windows)
" _vimrc is to windows what .vimrc is to unix
" copy _vimrc to:
" c:\Users\<username>\vim\_vimrc (assuming you installed vim to this path ; recommended)
" #########################################
" ########## Useful VIM Settings ##########
" #########################################
set nocompatible
filetype off
" ###################################################################
" ########## Set the runtime path to include Vundle and initialize ##
" ###################################################################
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
"
" (for Windows)
" set rtp+=$HOME/.vim/bundle/Vundle.vim/
" call vundle#begin('$HOME/.vim/bundle/')
" #############################
" ########## Plugins ##########
" #############################
Plugin 'VundleVim/Vundle.vim' " let Vundle manage Vundle, required
Plugin 'tpope/vim-fugitive'
Plugin 'easymotion/vim-easymotion'
Plugin 'vim-airline/vim-airline'
Plugin 'vim-airline/vim-airline-themes'
Plugin 'kien/ctrlp.vim'
Plugin 'junegunn/goyo.vim'
Plugin 'tomtom/tcomment_vim'
Plugin 'dhruvasagar/vim-table-mode'
Plugin 'reedes/vim-colors-pencil'
Plugin 'scrooloose/nerdtree'
Plugin 'jistr/vim-nerdtree-tabs'
Plugin 'airblade/vim-gitgutter'
" Plugin 'pearofducks/ansible-vim'
" All of your Plugins must be added before these lines:
call vundle#end() " required
filetype plugin indent on " required
" To ignore plugin indent changes, instead use:
"filetype plugin on
" ################################################################
" ########## Put your non-Plugin stuff after this line ##########
" ################################################################
" Set NERDTree mapping
nnoremap <C-n> :NERDTreeToggle<CR>
" Go to next and previous buffer ; useful for switching tabs
nnoremap ;; :bn<CR>
nnoremap aa :bp<CR>
" Paste code with formating preserved
" set paste (:set nopaste to undo)
" Note: When enabled, this will break your jj/kk/jk imap rules to Esc
set laststatus=2
" Set Airline Theme
" https://github.com/vim-airline/vim-airline/wiki/Screenshots
let g:airline_theme='simple'
" Automatically displays all buffers when there's only one tab open.
let g:airline#extensions#tabline#enabled = 1
" Show word count
let g:airline#extensions#wordcount#enabled = 1
" Set large history and undo buffer
set history=1000
set undolevels=1000
" Enable vim-color-pencil when starting Goyo
function! s:goyo_enter()
colorscheme pencil
endfunction
function! s:goyo_leave()
:let g:airline_theme='simple'
endfunction
autocmd! User GoyoEnter nested call <SID>goyo_enter()
autocmd! User GoyoLeave nested call <SID>goyo_leave()
"Remove all trailing whitespace by pressing F5
nnoremap <F5> :let _s=@/<Bar>:%s/\s\+$//e<Bar>:let @/=_s<Bar><CR>
" Map jk, jj, and kk to <esc>
imap jj <esc>
imap kk <esc>
imap jk <esc>
" Easier split navigations
" Instead of ctrl+w followed by motion key, use ctrl-<motion key>
" And in case you've forgotten how to split windows:
" :vsp , vertical split
" :sp , horizontal split
nnoremap <C-J> <C-W><C-J>
nnoremap <C-K> <C-W><C-K>
nnoremap <C-L> <C-W><C-L>
nnoremap <C-H> <C-W><C-H>
" Normal Non-recursive Map (nnoremap) to expand vertical split window full screen
nnoremap <F2> <C-w>=
nnoremap <F3> <C-w><bar>
" Normal Non-recursive Map (nnoremap) to expand present windows horizontally
nnoremap <F4> <C-w>_
" Keep Searched Text Centered
nmap n nzz
nmap N Nzz
nmap # #zz
nmap g* g*zz
nmap g# g#zz
" Keep Cursor Centered Vertically
nmap j jzz
nmap k kzz
" Set the font and height
set guifont=Courier_New:h15
" Set autoindent
" ctrl-d to un-indent
set autoindent
" Set line number by default
set relativenumber
" Use linenumber in Insert mode
" Use Relativenumber in CMD mode
autocmd InsertEnter * :set number
autocmd InsertLeave * :set relativenumber
" Highlight those annoying whitespaces
" Source: http://vim.wikia.com/wiki/Highlight_unwanted_spaces
highlight ExtraWhitespace ctermbg=red guibg=red
match ExtraWhitespace /\s\+$/
autocmd BufWinEnter * match ExtraWhitespace /\s\+$/
autocmd InsertEnter * match ExtraWhitespace /\s\+\%#\@<!$/
autocmd InsertLeave * match ExtraWhitespace /\s\+$/
autocmd BufWinLeave * call clearmatches()
" Fold lines that start with /* and end of */
" zM => fold all
" zR => unfold all
" za => toggle fold
set foldmethod=marker
set foldmarker=/*,*/
" Enable syntax and plugins (for newtrw)
syntax enable
filetype plugin on
" Color scheme
" Useful for setting gVIM color scheme
" To view entire list of color schemes, type :colorscheme <ctl+d>
colorscheme evening
" The following are commented out as they cause vim to behave a lot
" differently from regular Vi. They are highly recommended though.
set showcmd " Show (partial) command in status line.
set showmatch " Show matching brackets.
set ignorecase " Do case insensitive matching
set smartcase " Do smart case matching
set incsearch " Incremental search
set hidden " Hide buffers when they are abandoned
"set mouse=a " Enable mouse usage (all modes)
" Note: If you enable mouse usage, right-clicking
" will activate visual mode preventing you from
" pasting to file.
set colorcolumn=79