forked from chenzhiwei/vim
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.vimrc.real
176 lines (142 loc) · 4.22 KB
/
.vimrc.real
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
"Get out of VI's compatible mode
set nocompatible
"I like using light background terminal
set background=light
"Sets how many lines of history VIM has to remember
set history=1000
"Enable filetype plugin
filetype on
filetype plugin on
filetype indent on
"Set to auto read when a file is changed from the outside
set autoread
"Enable syntax hl
syntax on
syntax enable
"Always show current position
set ruler
"Show line number and wrap line
set nu
set wrap
"Set backspace
set backspace=eol,start,indent
"Backspace and cursor keys wrap to
set whichwrap+=<,>,h,l
"Set magic on
set magic
"show matching bracets
set showmatch
"How many tenths of a second to blink
set mat=4
"Text options
set expandtab
set shiftwidth=4
set tabstop=4
set softtabstop=4
set smarttab
set lbr
"Auto/Smart/C-style indent
set ai
set si
set cindent
"Chinese support
set encoding=utf-8
set fencs=utf-8,ucs-bom,gb18030,gbk,gb2312,cp936
set ambiwidth=single
"Highlight search things
set hlsearch
set incsearch
"Auto-complete filename as in bash
set wildmode=list:longest,full
"Set the comment line DarkBlue
"highlight Comment ctermfg=DarkBlue
"Highlight trailing spaces/tabs
match ErrorMsg '\s\+$'
"Highligh trailing spaces/tabs in c language files
let c_space_errors=1
"Highlight settings in Visual select and Diff mode
highlight Search ctermfg=DarkBlue
highlight Visual ctermfg=White ctermbg=LightBlue
highlight DiffAdd cterm=bold ctermbg=DarkBlue
highlight DiffDelete cterm=bold ctermbg=DarkBlue
highlight DiffChange cterm=bold ctermbg=DarkBlue
highlight DiffText cterm=bold ctermfg=white ctermbg=Red
" highlight DiffText cterm=bold ctermfg=10 ctermbg=88 gui=none guifg=bg guibg=Red
"Don't like q:
map q <Nop>
"When highlight words, don't jump to next
"nnoremap * *`` # This will cause screen flicker
nnoremap * :let @/='\<<C-R>=expand("<cword>")<CR>\>'<CR>:set hls<CR>
"Map :Q to :q, :W to :w
cnoreabbrev Q <C-r>=(getcmdtype()==':'? 'q!' : 'Q')<CR>
cnoreabbrev W <C-r>=(getcmdtype()==':'? 'w' : 'W')<CR>
cnoreabbrev Wq <C-r>=(getcmdtype()==':'? 'wq' : 'Wq')<CR>
cnoreabbrev WQ <C-r>=(getcmdtype()==':'? 'wq' : 'WQ')<CR>
"Map VIM command/insert mode shortcut to bash shortcut
cnoremap <C-a> <Home>
cnoremap <C-e> <End>
cnoremap <C-b> <Left>
cnoremap <C-f> <Right>
cnoremap <C-d> <Del>
cnoremap <C-k> <Nop>
inoremap <C-a> <Home>
inoremap <C-e> <End>
inoremap <C-k> <Up>
inoremap <C-j> <Down>
inoremap <C-b> <Left>
inoremap <C-f> <Right>
inoremap <C-d> <Del>
"when pasting from system clipboard, F2 to toggle paste mode
set pastetoggle=<F2>
"autocmd settings
if !exists("autocommands_loaded")
let autocommands_loaded = 1
"Strip trailing withspace
fun! StripTrailingWhitespace()
let l = line(".")
let c = col(".")
" if &ft =~ 'mkd'
" return
" endif
%s/\s\+$//e
call cursor(l, c)
endfun
autocmd BufWritePre * call StripTrailingWhitespace()
autocmd BufNewFile,BufRead *.{css,htm,html,js,json,rb,xml,yaml,yml} set sw=2 ts=2 sts=2
" autocmd BufNewFile,BufRead *.json if !exists("filetype")|set ft=javascript|endif
" autocmd BufWinLeave *.sh :![ -x % ] || chmod +x %
endif
"FileType
autocmd FileType go setlocal noexpandtab
autocmd FileType yaml setlocal shiftwidth=2 tabstop=2 softtabstop=2
autocmd FileType javascript setlocal shiftwidth=2 tabstop=2 softtabstop=2
"Use bash syntax highlight
let g:is_bash = 1
"vim-plug setting
fun! VimPlug()
call plug#begin('~/.vim/.bundle')
if has('nvim')
Plug 'Shougo/deoplete.nvim', {'do': ':UpdateRemotePlugins'}
else
Plug 'Shougo/deoplete.nvim'
Plug 'roxma/nvim-yarp'
Plug 'roxma/vim-hug-neovim-rpc'
endif
Plug 'scrooloose/nerdtree', {'on': 'NERDTreeToggle'}
Plug 'fatih/vim-go', {'tag': '*', 'do': ':GoUpdateBinaries'}
Plug 'ConradIrwin/vim-bracketed-paste'
Plug 'plasticboy/vim-markdown'
Plug 'vim-airline/vim-airline'
call plug#end()
"deoplete plugin
let g:deoplete#enable_at_startup = 1
call deoplete#custom#option('on_insert_enter', v:false)
endfun
silent! call VimPlug()
"deoplete settings
"select first menu item
"set completeopt+=menuone,noinsert
"Open/Close NERDTree
nmap <F7> :NERDTreeToggle<CR>
"vim-markdown plugin
let g:vim_markdown_folding_disabled = 1