forked from gaohelong/bigvim
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvimrc
264 lines (206 loc) · 7.92 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
" ----------------------------------------------------------------------------
" Author: ruanyl
" Version: 1.1
" ----------------------------------------------------------------------------
set nocompatible
"Load plugins
if filereadable(expand("~/.vim/vimrc.before"))
source ~/.vim/vimrc.before
endif
"Load plugins
if filereadable(expand("~/.vim/vimrc.bundles"))
source ~/.vim/vimrc.bundles
endif
filetype plugin indent on
syntax enable
syntax on
colorscheme gruvbox
"colorscheme solarized
"colorscheme molokai
"colorscheme desert
set background=dark
set t_Co=256
set history=200 "history: number of command-lines remembered
set autoread " auto reload file after being modified
set shortmess=atI " do not show initial page
set nobackup
set noswapfile
set cursorcolumn " highlight current column
set cursorline " highlight current line
set t_ti= t_te= " alway show the content on the screen after exist VIM
set mouse-=a " disable mouse
set selection=inclusive "set selection=exclusive
set selectmode=mouse,key
set title " change the terminal's title
set novisualbell " don't beep
set noerrorbells " don't beep
set t_vb=
set tm=500
set nostartofline " keep cursor postion when switching between buffers
set number " show line number
set nowrap " disable wrap
"set list
"set listchars=tab:›\ ,trail:•,extends:❯,precedes:❮
set showmatch " show matched brackets
set mat=2 " How many tenths of a second to blink when matching brackets
set hlsearch " highlight the searching words
set ignorecase " ingnore case when do searching
set incsearch " instant search
set smartcase " ignore case if search pattern is all lowercase, case-sensitive otherwise
set foldenable " code folding
set foldmethod=indent " options: manual, indent, expr, syntax, diff, marker
set foldlevel=99
set smartindent " Do smart autoindenting when starting a new line
set autoindent " always set autoindenting on
set tabstop=4 " Number of spaces that a <Tab> in the file counts for.
set shiftwidth=4 " number of spaces to use for autoindenting
set softtabstop=4 " Number of spaces that a <Tab> counts for while performing editing operations
set smarttab
set expandtab " when typing <Tab>, use <space> instead
set shiftround " use multiple of shiftwidth when indenting with '<' and '>'
set hidden " A buffer becomes hidden when it is abandoned
set wildmode=longest:full,full
set ttyfast
set relativenumber " show relative line number
set ruler " show the current line number and column number
set showcmd " show the current typing command
set noshowmode " Show current mode
set scrolloff=7 " Set 7 lines to the cursor - when moving vertically using j/k
" File encode:encode for varied filetype
set encoding=utf-8
set fileencodings=utf-8,ucs-bom,cp936,gb18030,big5,euc-jp,euc-kr,latin1
set helplang=en
set termencoding=utf-8
set ffs=unix,dos,mac " Use Unix as the standard file type
set formatoptions+=m
set formatoptions+=B " When joining lines, don't insert a space between two multi-byte characters.
set completeopt=longest,menu " behaviour of insert mode completion
set wildmenu " auto complete command
set wildignore=**.o,*~,.swp,*.bak,*.pyc,*.class " Ignore compiled files
set viminfo^=% " Remember info about open buffers on close
set magic " For regular expressions turn magic on
set backspace=eol,start,indent " Configure backspace so it acts as it should act
set whichwrap+=<,>,h,l
set pastetoggle=<F5> " when in insert mode, toggle between 'paste' and 'nopaste'
"let &colorcolumn="80,".join(range(120,999),",")
let &colorcolumn="120"
autocmd InsertEnter * :set norelativenumber " no relativenumber in insert mode
autocmd InsertLeave * :set relativenumber " show relativenumber when leave insert mode
"create undo file
if has('persistent_undo')
set undofile " So is persistent undo ...
set undolevels=1000 " Maximum number of changes that can be undone
set undoreload=10000 " Maximum number lines to save for undo on a buffer reload
set undodir=~/.undodir/
endif
if has('statusline')
set laststatus=2
set statusline=%<%f\ " Filename
set statusline+=%w%h%m%r " Options
set statusline+=%{fugitive#statusline()} " Git Hotness
set statusline+=\ [%{&ff}/%Y] " Filetype
set statusline+=\ [%{getcwd()}] " Current dir
set statusline+=%=%-14.(%l,%c%V%)\ %p%% " Right aligned file nav info
endif
if has("autocmd")
au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
endif
au InsertLeave * set nopaste
"close popup menu when leave insert mode
autocmd InsertLeave * if pumvisible() == 0|pclose|endif
inoremap <expr> <Down> pumvisible() ? "\<C-n>" : "\<Down>"
inoremap <expr> <Up> pumvisible() ? "\<C-p>" : "\<Up>"
inoremap <expr> <PageDown> pumvisible() ? "\<PageDown>\<C-p>\<C-n>" : "\<PageDown>"
inoremap <expr> <PageUp> pumvisible() ? "\<PageUp>\<C-p>\<C-n>" : "\<PageUp>"
autocmd FileType python set tabstop=4 shiftwidth=4 expandtab ai
autocmd FileType javascript,json,css,scss,html set tabstop=2 shiftwidth=2 expandtab ai
autocmd BufReadPre * if getfsize(expand("%")) > 10000000 | syntax off | endif
" ----------------------------------------------------------------------------
" Key Mappings:Customized keys
" ----------------------------------------------------------------------------
command! W w !sudo tee % > /dev/null
"goto older/newer position in change list
nnoremap <silent> ( g;
nnoremap <silent> ) g,
"replace currently selected text with default register without yanking it
vnoremap p "_dP
" use ctrl-c to copy to system clipboard
vnoremap <C-c> "*y
" use <C-V> to paste yanked content
inoremap <C-V> <C-R>"
"Treat long lines as break lines (useful when moving around in them)
noremap j gj
noremap k gk
" better command line editing
cnoremap <C-j> <t_kd>
cnoremap <C-k> <t_ku>
cnoremap <C-a> <Home>
cnoremap <C-e> <End>
"Smart way to move between windows
noremap <C-j> <C-W>j
noremap <C-k> <C-W>k
noremap <C-h> <C-W>h
noremap <C-l> <C-W>l
" Go to home and end using capitalized directions
noremap H 0
noremap L $
noremap Y y$
" Remap VIM 0 to first non-blank character
noremap 0 ^
" Speed up scrolling of the viewport slightly
nnoremap <C-e> 2<C-e>
nnoremap <C-y> 2<C-y>
"no Highlight
noremap <silent><leader>/ :nohls<CR>
" I can type :help on my own, thanks.
noremap <F1> <Esc>"
nnoremap ; :
nnoremap ' :b
"Keep search pattern at the center of the screen."
nnoremap <silent> n nzz
nnoremap <silent> N Nzz
nnoremap <silent> * *zz
nnoremap <silent> # #zz
nnoremap <silent> g* g*zz
"Use 'm/M' to move among buffers
noremap m :bn<CR>
noremap M :bp<CR>
" remap U to <C-r> for easier redo
nnoremap U <C-r>
" select all
noremap <Leader>sa ggVG
nnoremap dp :diffput<CR>
nnoremap dg :diffget<CR>
" toggle between two buffers
nnoremap t <C-^>
"" Vmap for maintain Visual Mode after shifting > and <
vnoremap < <gv
vnoremap > >gv
"" Move visual block
vnoremap J :m '>+1<CR>gv=gv
vnoremap K :m '<-2<CR>gv=gv
" Quick move in insert mode
inoremap <C-o> <Esc>o
inoremap <C-a> <Home>
inoremap <C-e> <End>
if has('macunix')
" pbcopy for OSX copy/paste
vnoremap <C-x> :!pbcopy<CR>
vnoremap <C-c> :w !pbcopy<CR><CR>
endif
hi! link SignColumn LineNr
hi! link ShowMarksHLl DiffAdd
hi! link ShowMarksHLu DiffChange
" for error highlight
highlight clear SpellBad
highlight SpellBad term=standout ctermfg=1 term=underline cterm=underline
highlight clear SpellCap
highlight SpellCap term=underline cterm=underline
highlight clear SpellRare
highlight SpellRare term=underline cterm=underline
highlight clear SpellLocal
highlight SpellLocal term=underline cterm=underline
"Load local settings
if filereadable(expand("~/.vim/vimrc.local"))
source ~/.vim/vimrc.local
endif