vimenv

configure vim environment
git clone git://git.unixkoans.com/vimenv.git
Log | Files | Refs | Submodules

_vimrc (2714B)


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
"
" author:    Xu Xiaodong <xxdlhy@gmail.com>
" modified:  2016 Dec 06
"

"-- source --"

source ~/.vim/conf/abbrevs.vim
source ~/.vim/conf/base.vim
source ~/.vim/conf/funcs.vim
source ~/.vim/conf/latex.vim
source ~/.vim/conf/perl.vim
source ~/.vim/conf/plugin.vim
source ~/.vim/conf/ruby.vim

"-- base --"

set nocompatible
set hidden
set relativenumber
set ruler
set cursorline
set wildmenu
set lazyredraw
set splitbelow

set history=500
set scrolloff=6
set cmdheight=1
set display=lastline
set omnifunc=syntaxcomplete#Complete

set laststatus=2
" set statusline=\ [%n]\ \ %F%m%r\ \ %h%y%w\ \ [%l,%c]\ \ [%L]\ \ [%P]

syntax on

"-- colorscheme --"

if &t_Co < 256
    colorscheme miro8
else
    set background=dark
    colorscheme gruvbox
endif

"-- file --"

filetype plugin indent on

set autoread
set noswapfile
set nowritebackup

"set encoding=utf-8
set fileencoding=utf-8
set fileencodings=ucs-bom,utf-8,gb18030,default

"-- format --"

set expandtab
set smarttab
set shiftround
set tabstop=4
set shiftwidth=4
set softtabstop=4
set textwidth=79

set autoindent
set smartindent
set copyindent

set foldenable
set foldmethod=marker
set foldlevelstart=10
set foldnestmax=10

set backspace=indent,eol,start
set iskeyword+=:
set matchpairs+=<:>
set whichwrap+=<,>,h,l

set nolist
set listchars=tab:›\ ,eol:¬

"set formatprg=par-format\ -w78

"-- search --"

set smartcase
set incsearch
set hlsearch
set gdefault
set showmatch
set inccommand=nosplit

set grepprg=ack
set grepformat=%f:%l:%m

"-- map --"

let mapleader=','

map ; :

" exit back to normal mode
imap jj <esc>

nmap <leader>w :w!<cr>
nmap <leader>q :qa<cr>

nmap <leader>s :source $MYVIMRC<cr>
nmap <leader>e :e! $MYVIMRC<cr>

" formatting paragraph
nmap Q gqap"
vmap Q gq

" select window
nmap <C-h> <C-w>h
nmap <C-j> <C-w>j
nmap <C-k> <C-w>k
nmap <C-l> <C-w>l

" open a new vertical split and switch over to it
nmap <leader>l <c-w>v<c-w>l

" horizontal split
nmap <leader>- <c-w>s<c-w>j

" close window
nmap <leader>cw :close<cr>

" command history
cmap <C-p> <Up>
cmap <C-n> <Down>

" grep
map <leader>n :cn<cr>
map <leader>p :cp<cr>

" search
map <space> /
map <m-space> ?
nmap <silent> <leader>/ :nohlsearch<cr>

" highlight last inserted text
nnoremap gV `[v`]

" paste mode
set pastetoggle=<f2>

" remove indenting on empty lines
map <f3> :%s/\s*$//g<cr>:noh<cr>''

" strip all trailing whitespace in the current file
nmap <leader>W :%s/\s\+$//<cr>:let @/=''<cr>

" remove the Windows ^M
nmap <leader>m mmHmt:%s/<C-V><cr>//ge<cr>'tzt'm

"-- other --"

" c
autocmd BufRead,BufNewFile *.h set filetype=c
autocmd FileType c setlocal expandtab tabstop=8 shiftwidth=8 softtabstop=8

" reload .vimrc
autocmd! BufWritePost vimrc source ~/.vimrc