-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathvimrc
254 lines (208 loc) · 5.83 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
" .vimrc
" Vim Settings {{{
map <space> <nop>
let mapleader = " "
" let g:mapleader = " "
syntax on
set encoding=utf-8
set fileencodings=utf-8,chinese,latin-1
set fileformats=unix,dos,mac
set nobomb
set nobackup
set nowritebackup
set noswapfile
set history=1024
set ruler
set showcmd
set showmode
set wrap
set linebreak
set autoread
" set autowrite
" set autochdir
set hidden
set belloff=all
set nojoinspaces
set backspace=indent,eol,start
set foldmethod=marker
set nospell spelllang=en_us,cjk
set shiftwidth=2
set softtabstop=2
set tabstop=2
set expandtab
set scrolloff=5
set sidescroll=1 " zh zl
set sidescrolloff=10
" set nolist
" set list listchars=tab:»·,trail:·,nbsp:·
if filereadable(expand("~/.vimrc.bundles"))
source ~/.vimrc.bundles
endif
set nocompatible
filetype plugin indent on
augroup vimrcEx
autocmd!
" When editing a file, always jump to the last known cursor position.
" Don't do it for commit messages, when the position is invalid, or when
" inside an event handler (happens when dropping a file on gvim).
autocmd BufReadPost *
\ if &ft != 'gitcommit' && line("'\"") > 0 && line("'\"") <= line("$") |
\ exe "normal g`\"" |
\ endif
" Set syntax highlighting for specific file types
autocmd BufRead,BufNewFile Appraisals set filetype=ruby
autocmd BufRead,BufNewFile *.{md,mdown,mkd,mkdn,markdown,mdwn} set filetype=markdown
autocmd FileType c set omnifunc=ccomplete#Complete
autocmd FileType python set omnifunc=pythoncomplete#Complete
" autocmd FileType javascript set omnifunc=javascriptcomplete#CompleteJS
autocmd FileType html set omnifunc=htmlcomplete#CompleteTags
autocmd FileType css set omnifunc=csscomplete#CompleteCSS
autocmd FileType php set omnifunc=phpcomplete#CompletePHP
autocmd FileType sql set omnifunc=sqlcomplete#Completesql
autocmd FileType css,scss,less,html setl iskeyword+=-
augroup END
" When the type of shell script is /bin/sh, assume a POSIX-compatible
" shell for syntax highlighting purposes.
let g:is_posix = 1
if v:version >= 703
set undofile
set undodir=~/.cache/vim/undoes
endif
if v:version >= 800
set tagcase=match
endif
set backupdir=~/.cache/vim/backups
" set directory=~/tmp/
set colorcolumn=81
set nonumber
set norelativenumber
set numberwidth=4
set sidescroll=1
set sidescrolloff=10
set splitbelow
set splitright
set equalalways
set autoindent
set linespace=3
set history=1024
set undoreload=1024
set timeoutlen=500
set ttimeoutlen=10
set updatetime=100
" Always use vertical diffs
" set diffopt+=vertical
" set whichwrap=b,s
set wildmenu
" set wildmode=list:longest,list:full
set wildmode=longest:full,full
set wildignore+=.hg,.git,.svn " Version control
set wildignore+=*.jpg,*.bmp,*.gif,*.png,*.jpeg " binary images
set wildignore+=*.o,*.obj,*.exe,*.dll,*.manifest " compiled object files
set wildignore+=*.sw? " Vim swap files
set wildignore+=*.DS_Store " OSX bullshit
set wildignore+=*.pyc " Python byte code
set wildignore+=*.orig " Merge resolution files
set ofu=syntaxcomplete#Complete
set ruler
set matchtime=2
set magic
set ignorecase
set smartcase
set hlsearch
set incsearch
set showmatch
set cmdheight=2
set laststatus=2
highlight StatusLine term=bold,reverse cterm=bold,reverse
set statusline=%<\ [%F]
set statusline+=\ [%{&encoding}, " encoding
set statusline+=%{&fileformat}%{\"\".((exists(\"+bomb\")\ &&\ &bomb)?\",BOM\":\"\").\"\"}]%m
set statusline+=%=\ %y\ %l,\ %c\ \<%P\>
set complete+=kspell
set complete-=u
set complete-=i
set complete-=t
" Set spellfile to location that is guaranteed to exist, can be symlinked to
" Dropbox or kept in Git and managed outside of thoughtbot/dotfiles using rcm.
set spellfile=$HOME/Sync/vim-spell-en.utf-8.add
" set sessionoptions=
" \blank,buffers,curdir,folds,globals,help,localoptions,
" \options,tabpages,winsize,resize,winpos,winsize
set formatoptions+=mM
set mouse=
set ttymouse=
set shortmess=atIc
set nrformats=
" set tags=tags
set tags+=gems.tags
" Speed up for macros
set lazyredraw
" }}}
" Theme {{{
" set background=light
set background=dark
let g:gruvbox_invert_selection=0
let g:gruvbox_contrast_dark='soft'
let g:gruvbox_contrast_light='soft'
colorscheme gruvbox
" }}}
" Mapping {{{
nnoremap k gk
nnoremap gk k
nnoremap j gj
nnoremap gj j
nnoremap B ^
nnoremap E $
" highlight last inserted text
nnoremap gV `[v`]
" Copy filename to clipboard
nmap ,cn :let @*=expand("%"). ':' . line(".")<CR>
nmap ,cs :let @*=expand("%")<CR>
nmap ,cf :let @*=expand("%:t")<CR>
nmap ,cl :let @*=expand("%:p")<CR>
" Move to prev/next buffer
nnoremap [l :lprevious<CR>
nnoremap ]l :lnext<CR>
nnoremap [t :tabprevious<CR>
nnoremap ]t :tabnext<CR>
nnoremap [c :cprevious<CR>
nnoremap ]c :cnext<CR>
noremap <silent> <C-s> :update!<CR>
vnoremap <silent> <C-s> <C-c>:update!<CR>
inoremap <silent> <C-s> <C-o>:update!<CR>
nnoremap n nzzzv
nnoremap N Nzzzv
nnoremap g; g;zz
nnoremap g, g,zz
nmap <leader><c-g> <c-g>
nmap <leader><c-l> <c-l>
nnoremap t<C-]> :tabnew %<CR>g<C-]>
nnoremap <leader>ct :silent ! ctags -R --languages=ruby --exclude=.git --exclude=log -f tags<cr>
" inoremap <C-e> <C-k>
" map <C-j> <C-w>j
" map <C-k> <C-w>k
" map <C-h> <C-w>h
" map <C-l> <C-w>l
" map <C-w>; <C-w>p
noremap <right> gt
noremap <left> gT
noremap <up> :lprevious<CR>
noremap <down> :lnext<CR>
imap <C-]> <C-x><C-]>
" inoremap <C-g> <C-x><C-o>
" imap <C-l> <C-x><c-l>
" Convert all tabs to spaces
" map <leader>ct :retab<cr>
map <leader>co :botright copen<cr>
" When pressing <leader>cd switch to the directory of the open buffer
map <leader>cd :cd %:p:h<cr>
map <silent> <leader><cr> :nohlsearch<cr>
" Spell
map <leader>ss :setlocal spell!<cr>
map <leader>sn ]s
map <leader>sp [s
map <leader>sa zg
map <leader>s? z=
" Remove the Windows ^M - when the encodings gets messed up
noremap <leader><leader>m mmHmt:%s/<C-V><cr>//ge<cr>'tzt'm
" }}}