forked from PeterDaveHello/Unitial
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvimrc
123 lines (97 loc) · 3.73 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
" charset
set encoding=utf-8 "enc, vim buffer charset, NOT the file's charset
set fileencoding=utf-8 "fenc, default save charset
"fencs, default opening charset priority (as auto detection)
set fileencodings=utf-8,big5,gb2312,gb18030,gbk,default
" enable features which are not Vi compatible but really really nice.
set nocompatible "nocp
" default no bomb for utf-8
set nobomb
" expand TABs to spaces
set expandtab "et
" set TAB's width
set tabstop=4 "ts
" auto indent width
set shiftwidth=4 "sw
" use the indent of the previous line for a newly created line
set autoindent "ai
" 256 color mode
set t_Co=256
" show the ruler for the cursor
set ruler "ru
" show line numbers
set number "nu
" show the search results before stop typing
set incsearch "is
" highlight search results
set hlsearch "hls
" case-insensitive search
set ignorecase "ic
" smart search (override 'ic' when pattern has uppers)
set smartcase "scs
" enable backspace in insert mode
set backspace=2 "bs
" file formats priority when try to read a file
set fileformats=unix,dos,mac "ffs
" set statusbar
set statusline+=%f "filename
set statusline+=%m "modified flag
set statusline+=%r "read only flag
set statusline+=\ \%y "filetype
set statusline+=%= "left/right separator
set statusline+=%#warningmsg# "show the errors/warning in the status line
set statusline+=%h "help file flag
set statusline+=%* "color off
set statusline+=\ [%{&ff}\]\ "fileformat (unix, dos, mac ...)
set statusline+=%=%{\"[\".(&fenc==\"\"?&enc:&fenc).((exists(\"+bomb\")\ &&\ &bomb)?\",B\":\"\").\"]\ \"} "file charset
set statusline+=[%l,%c] "cursor line,column
set statusline+=\ \[%L\ lines\] "total lines
set statusline+=\ [%P] "percent through file
set statusline+=\ %a "if open multiple files, show current file and and the number of all files
" display a status line at the bottom of the window
set laststatus=2 "ls
" show as much as possible of the last line, instead of '@' symbol
set display+=lastline
" set code folding feature
set foldmethod=indent "fdm
set foldnestmax=5 "fdn max fold level
set foldlevel=5 "fdl default fold level
" enable mouse in all mode
" set mouse=a
" hichlight current line
set cursorline
" highlight syntax
syntax on
" color scheme
colorscheme kolor
" make whitespaces and TABs visible
"l
set list
"lcs
set listchars=tab:>-,trail:·
highlight SpecialKey guifg=DarkGray
" set temp dirs, can speedup 100x when working on fuse via internet or nfs
"set backupdir=~/.vim/bak/
"set directory=~/.vim/swp/
"set undodir=~/.vim/undo/
" map hot key <Ctrl>+m to switch paste mode
map <C-o> :set paste!<BAR>set paste?<CR>
" map hot key <Ctrl>+n to switch if shows line numbers
map <C-n> :set nu!<BAR>set nu?<CR>
" map hot key <Ctrl>+h to switch if highlights current working column
map <C-g> :set cursorcolumn!<BAR>set cursorcolumn?<CR>
" map hot key <Ctrl>+h to switch if highlights current working line
map <C-h> :set cursorline!<BAR>set cursorline?<CR>
"=== setting depends on filetype ==="
" au, autocommand
autocmd FileType make,gitconfig,gitcommit,apache setlocal et!
autocmd FileType html,css,javascript setlocal sw=2 ts=2
"=== manually setting filetype ==="
" au, autocommand
autocmd BufRead,BufNewFile *.plt set filetype=gnuplot
autocmd BufRead,BufNewFile *.md set filetype=markdown
"=== IF YOU WANT TO USE THE FOLLOWING FEATURE, PLEASE UNCOMMENT IT BY YOURSELF ==="
" remember and go to the last used location automatically.
"autocmd BufReadPost * if line("'\"") > 0|if line("'\"") <= line("$")|exe("norm '\"")|else|exe "norm $"|endif|endif
" auto remove trailing whitespace when saving file
"autocmd BufWritePre * :%s/\s\+$//e