This repository has been archived by the owner on Sep 14, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy path.vimrc
312 lines (242 loc) · 8.28 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
scripte utf-8
" vim: set fenc=utf-8 tw=0:
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" General
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Revert all command settings before proceeding with other settings below
set all&
" Work in Vim compatible not Vi compatible
set nocompatible
" Keep 50 commands and 50 search patterns in the history.
" 50 is undo limit.
set history=100
" No need to understand this. Leave this when using Vim.
set magic
" No swap file. It's messy.
set noswapfile
" No backup file. You take your risk on your own.
set nobackup
" Turn on plugin and indent, depending on file type
filetype plugin indent on
" Wait for a key code forever.
" Wait for a mapped key sequence to complete within ttimeoutlen.
set notimeout ttimeout
" In Milliseconds
set timeoutlen=3000 ttimeoutlen=100
" Not redraw while executing macros, and commands.
set lazyredraw
set visualbell
" set mouse=a
set termguicolors
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Vim Plugin Settings
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Load plugins when starting up
set loadplugins
filetype off " required
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" alternatively, pass a path where Vundle should install plugins
"call vundle#begin('~/some/path/here')
" let Vundle manage Vundle, required
Plugin 'VundleVim/Vundle.vim'
Plugin 'tpope/vim-fugitive'
Plugin 'tpope/vim-unimpaired'
Plugin 'scrooloose/nerdtree'
Plugin 'majutsushi/tagbar'
"Plugin 'altercation/vim-colors-solarized'
Plugin 'vim-airline/vim-airline'
Plugin 'vim-airline/vim-airline-themes'
Plugin 'inkarkat/vim-ingo-library'
Plugin 'inkarkat/vim-mark'
Plugin 'ervandew/supertab'
Plugin 'ludovicchabant/vim-gutentags'
Plugin 'skywind3000/gutentags_plus'
" All of your Plugins must be added before the following line
call vundle#end() " required
filetype plugin indent on " required
" To ignore plugin indent changes, instead use:
"filetype plugin on
"
" Brief help
" :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
" Put your non-Plugin stuff after this line
" Ease my eyes
"colorscheme solarized
" Set tagbar
let g:tagbar_left = 1
let g:tagbar_width = 30
let g:tagbar_sort = 0
" Set NERDTree position
let g:NERDTreeWinPos='right'
" Set airline
let g:airline_powerline_fonts = 1
let g:airline_theme='dark'
"let g:airline_solarized_bg='dark'
let g:airline#extensions#tabline#enabled = 1
let g:airline#extensions#tabline#formatter = 'unique_tail'
let g:airline#extensions#tagbar#enabled = 1
"if !exists('g:airline_symbols')
" let g:airline_symbols = {}
"endif
"let g:airline_symbols.branch = ''
"let g:airline_symbols.linenr = ''
"let g:airline_symbols.maxlinenr = ''
"let g:airline_section_error = ''
"let g:airline_section_warning = ''
"let g:airline_symbols.notexists = ''
autocmd BufDelete * call airline#extensions#tabline#buflist#invalidate()
" Set Supertab
let g:SuperTabDefaultCompletionType = "<c-n>"
" Set vim-gutentags and gutentags_plus
let g:gutentags_modules = ['ctags', 'gtags_cscope']
let g:gutentags_project_root = ['.root']
let g:gutentags_cache_dir = expand('~/.cache/tags')
let g:gutentags_plus_switch = 1
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Editing
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Tell Vim to delete the white space at the start of the line, a line break
" and the character before where Insert mode started.
set backspace=indent,eol,start
" Display the current cursor position in the lower right corner of the
" Vim window. But for now this is no londer used thanks to airline plugin.
"set ruler
" Display an incomplete vim command in the lower right corner of the Vim window
" This is no longer used thanks to AutoComplPop plugin
"set showcmd
" Display line numbers
set nu
" Set line number width
set numberwidth=5
" Do not wrap lines
set nowrap
" Move the cursor to the first non-blank of the line when Vim
" move commands are used.
set startofline
" Turn on syntax highlighting
syntax on
" Whatever floats in your boat
set background=dark
"set background=light
" Delete trailing spaces at eol when a file is saved.
func! DeleteTrailingWS()
exe "normal mz"
%s/\s\+$//ge
exe "normal `z"
endfunc
autocmd BufWrite * :call DeleteTrailingWS()
" Locate the cursor in the last position when Vim is closed
au BufReadPost *
\ if line("'\"") > 0 && line("'\"") <= line("$") |
\ exe "norm g`\"" |
\ endif
" Set 80, 100 column guideline
set colorcolumn=100
highlight ColorColumn ctermbg=red
let &colorcolumn="80,".join(range(100,100),",")
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Tab & Indent
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Set tab size
set tabstop=4
set shiftwidth=4
set softtabstop=4
" Use spaces instead of tabs
set expandtab
" Work for C-like programs, but can also be used for other languages
set smartindent
" Copy indent from current line when starting a new line. This should be
" on when smartindent is used.
set autoindent
" Set indent for switch statement in C. Just my cup of tea.
set cinoptions=:0
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Encoding and Format
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Determine the 'fileencoding' of a file being opened.
set fileencodings=utf-8,cp949,cp932,euc-kr,shift-jis,big5,ucs-2le,latin1
" Represent data in memory
set encoding=utf-8
" Use only unix fileformat. "dos" can be added like "unix, dos"
" if you are a coward.
set fileformats=unix
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Search
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Highlight all matches
set hlsearch
" Not search wrap around the end of a file
set nowrapscan
" Ignore case in search patterns
set ignorecase
" Override ignorecase option if the search pattern contains an uppercase
" character.
set smartcase
" Show where the pattern matches as it was typed so far.
set incsearch
" Jump to one to the other using %. Various character can be added.
set matchpairs+=<:>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Shortcuts
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Show the man page when you press F1
func! Man()
let sm = expand("<cword>")
exe "!man -S 2:3:4:5:6:7:8:9:tcl:n:1:p:o ".sm
endfunc
map <F1> :call Man()<cr><cr>
" Save
map <F2> :w!<cr>
" Show a sidebar listing defines, variables, and functions
map <F3> :TagbarToggle<cr>
" Show a sidebar listing file system in tree view
map <F4> :NERDTreeToggle<cr>
" Fold/unfold a function body from brace to brace.
map <F5> v]}zf
map <F6> zo
" Clear all markers
map <F8> :MarkClear<cr> :noh<cr>
"map <F8> [i
"Map <F9> gd
" Step into the function.
func! Tj()
let st = expand("<cword>")
exe "tj ".st
endfunc
map <F11> :call Tj()<cr>
" Step out of the function.
map <F12> <c-T>
" Move around buffers by pressing ctrl+h or ctrl+l
map <C-h> :bprevious<cr>
map <C-l> :bnext<cr>
" Move between split windows
map <S-h> :wincmd h<cr>
map <S-l> :wincmd l<cr>
map <S-k> :wincmd k<cr>
map <S-j> :wincmd j<cr>
" Save and close the buffer
map ,w :bp <BAR> bd #<CR>
" Format source codes by clang-format. To use this clang-format must be
" installed.
map <C-K> :py3f ~/.vim/clang-format.py<cr>
imap <C-K> <c-o>:py3f ~/.vim/clang-format.py<cr>
" Move source codes by tab size. Tab is right move and Shift+tab is left.
vmap <Tab> >gv
vmap <S-Tab> <gv
" Toggle line number display
fu! ToggleNu()
let &nu = 1 - &nu
endf
map <leader>d :call ToggleNu()<CR>
" Toggle paste option. This is useful if you want to cut or copy some text
" from one window and paste it in Vim. Don't forget to toggle paste again once
" you're done with pasting.
map <leader>p :set invpaste paste?<CR>
set pastetoggle=<leader>p