forked from robbenmu/dotvim
-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.vim
executable file
·161 lines (136 loc) · 5.27 KB
/
config.vim
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
" General {
syntax on " syntax highlighting
filetype plugin indent on " automatically detect file types
set mouse=a " automatically enable mouse usage
set mousehide " hide the mouse cursor while typing
set encoding=utf-8
scriptencoding utf-8
set fileencodings=utf-8,ucs-bom,gb18030,gbk,gb2312,cp936
if has ('x') && has ('gui') " on Linux use + register for copy-paste
set clipboard=unnamedplus
elseif has ('gui') " one mac and windows, use * register for copy-paste
set clipboard=unnamed
endif
set shortmess+=filmnrxoOtT " abbrev. of messages (avoids 'hit enter')
set viewoptions=folds,options,cursor,unix,slash " better unix / windows compatibility
set virtualedit=onemore " allow for cursor beyond last character
set history=800 " Store a ton of history (default is 20)
set hidden " allow buffer switching without saving
"set autochdir " change directory to the current window
set backup
set backupdir=~/.vim/.backup
set directory=~/.vim/.tmp
" Persistent Undo
set undofile
set undodir=~/.vim/.undo
" }
" Formatting {
set nowrap " wrap long lines
set autoindent " indent at the same level of the previous line
set expandtab " tabs are spaces, not tabs
set shiftwidth=4 " use indents of 2 spaces
set tabstop=4 " an indentation every two columns
set softtabstop=4 " let backspace delete indent
set diffopt+=iwhite,vertical " ignore the difference of indents
set matchpairs=(:),{:},[:],<:>
set foldmethod=marker
set colorcolumn=80
" Remove trailing whitespaces and ^M chars
autocmd BufWritePre <buffer> call StripTrailingWhitespace()
autocmd FileType python setlocal expandtab shiftwidth=4 tabstop=4 softtabstop=4
" }
" UI {
set tabpagemax=15
set background=dark
if has('gui_macvim')
colorscheme gruvbox
else
let g:solarized_termcolors=256
colorscheme gruvbox
"colorscheme molokai
endif
let g:solarized_termtrans=1
let g:solarized_contrast='high'
let g:solarized_visibility='high'
if has('cmdline_info')
set ruler " show the ruler
set rulerformat=%30(%=\:b%n%y%m%r%w\ %l,%c%V\ %P%) " a ruler on steroids
set showcmd " show partial commands in status line and
" selected characters/lines in visual mode
endif
if has('statusline')
set laststatus=2
endif
"set rnu " relative line number
set nu
set numberwidth=4 " set the width of line number gutter column
set linespace=2 " set spaces between rows
set ignorecase " case insensitive search
set backspace=indent,eol,start " backspace for dummies
set smartcase " case sensitive when uc present
set showmatch " show matching brackets/parenthesis
set hlsearch " highlight search terms
set incsearch " find as you type search
set wildmenu " show list instead of just completing
set wildmode=list:longest,full " command <Tab> completion, list matches, then longest common part, then all
set whichwrap=b,s,h,l,<,>,[,] " backspace and cursor keys wrap to
set scrolljump=5 " lines to scroll when cursor leaves screen
set scrolloff=3 " minimum lines to keep above and below cursor
set foldenable " auto fold code
set cursorline " highlight current line
set anti " make text pretty
" }
" GUI Settings {
if has("gui_running") || has("gui_macvim")
set guioptions-=T " remove the MacVim's toolbar
if has('gui_macvim')
set transparency=5 " Make the window slightly transparent
endif
if has("gui_gtk2")
set guifont=menlo\ 15,Consolas\ 13
else
set guifont=menlo:h15,Consolas:h13
endif
endif
" }
" Key Mapping {
let mapleader = ","
let g:mapleader = ","
" Code folding options
nmap <leader>f0 :set foldlevel=0<CR>
nmap <leader>f1 :set foldlevel=1<CR>
nmap <leader>f2 :set foldlevel=2<CR>
nmap <leader>f3 :set foldlevel=3<CR>
nmap <leader>f4 :set foldlevel=4<CR>
nmap <leader>f5 :set foldlevel=5<CR>
nmap <leader>f6 :set foldlevel=6<CR>
nmap <leader>f7 :set foldlevel=7<CR>
nmap <leader>f8 :set foldlevel=8<CR>
nmap <leader>f9 :set foldlevel=9<CR>
" Easy indent for code blocks
nmap <tab> v>
nmap <s-tab> v<
vmap <tab> >gv
vmap <s-tab> <gv
nnoremap / /\v
vnoremap / /\v
" clearing highlighted search
nmap <silent> <leader><space> :nohlsearch<CR>
" toggle between relative and absolute numbering
nnoremap <F3> :NumbersToggle<CR>
" }
" file automatic header {
" http://blog.csdn.net/orangleliu/article/details/41902851
"
autocmd BufNewFile *.js 0r ~/.vim/vim_template/vim_js_header
autocmd BufNewFile *.js ks|call FileName()|'s
fun FileName()
if line("$") > 10
let l = 10 "这里是字母L 不是数字1
else
let l = line("$")
endif
exe "1," . l . "g/@file.*/s/@file.*/@file " .expand("%")
"最前面是数字1,这里的File Name: 要和模板中一致
endfun
" }