-
Notifications
You must be signed in to change notification settings - Fork 8
/
.vimrc
178 lines (159 loc) · 5.46 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
" VUNDLE PLUGINS {{{
set nocompatible " be iMproved, required
filetype off " required
" set the runtime path to include Vundle and initialize
set rtp+=/home/budiman/.vim/bundle/Vundle.vim
call vundle#begin()
" alternatively, pass a path where Vundle should install plugins
" call vundle#begin('~/some/path/here')
" let Vundle manage Vundle, required
Plugin 'VundleVim/Vundle.vim'
" Plugins
Plugin 'scrooloose/nerdtree'
Plugin 'tpope/vim-fugitive'
Plugin 'scrooloose/syntastic'
Plugin 'vim-airline/vim-airline'
Plugin 'vim-airline/vim-airline-themes'
Plugin 'valloric/youcompleteme'
" Color schemes
Plugin 'flazz/vim-colorschemes'
" All of your Plugins must be added before the following line
call vundle#end() " required
filetype plugin indent on " required
"}}}
" VIM BUILT IN OPTIONS
set nocompatible
filetype plugin indent on
syntax on
set mouse=a
set whichwrap=b,s,<,>,[,] " better arrow key cursor mapping
set relativenumber " relative line number
set number " display current actual line number too
set linebreak " only wrap at a character in breakat option
set hlsearch " highlight search
set expandtab " tab is spaces
set tabstop=2 " number of spaces in a tab
set shiftwidth=2 " number of spaces for indentation
set spell " enable spelling check
set noswapfile " do not add .swapfile after editing file
set foldmethod=marker " enable marker folding
set wildmenu
set title " show title in the terminal title bar
set wildignorecase " ignore case in directory autocompletion
set ignorecase smartcase " ignore case in searches, unless they contain upper-case letters
set background=dark
set t_Co=256
colorscheme badwolf
let mapleader = "," " leader key is ','
" PLUGIN OPTIONS GO HERE
" open up nerdtree file browser if no file is selected to be edited {{{
augroup nerdtree
autocmd StdinReadPre * let s:std_in=1
autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | endif
augroup END
" }}}
" vim-airline settings {{{
let g:airline_detect_modified=1
let g:airline_detect_paste=1
let g:airline_detect_spell=1
let g:airline_theme='base16_google'
set laststatus=2
" }}}
" syntastic settings {{{
set statusline+=%#warningmsg#
set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%*
let g:syntastic_always_populate_loc_list = 1
let g:syntastic_auto_loc_list = 1
let g:syntastic_check_on_open = 1
let g:syntastic_check_on_wq = 0
" }}}
" YCM functions {{{
set omnifunc=syntaxcomplete#Complete
" }}}
" MAPPINGS GO HERE
" Basic functions {{{
" Save, quit, save and quit
nmap <leader>w :w!<cr>
nmap <leader>q :qa!<cr>
nmap <leader>x :x<cr>
" Go to beginning and end of line
noremap B ^
noremap E $
" Toggle paste mode, paste using Ctrl+Shift+v inside paste mode will not add
" comments to the pasted content
set pastetoggle=<F2>
" }}}
" Tabbing and Splitting {{{
" Tabbing
map <leader>tn :tabnew<cr>
map <leader>tc :tabclose<cr>
map <leader><Right> :tabNext<cr>
map <leader><Left> :tabprevious<cr>
map <C-j> <C-W>j
map <C-k> <C-W>k
map <C-h> <C-W>h
map <C-l> <C-W>l
" Splitting
nmap <silent> <C-S-Up> :wincmd k<cr>
nmap <silent> <C-S-Down> :wincmd j<cr>
nmap <silent> <C-S-Left> :wincmd h<cr>
nmap <silent> <C-S-Right> :wincmd l<cr>
map <leader>sp :split<cr>
map <leader>vsp :vsplit<cr>
" }}}
" Move cursor intuitively, not by line number {{{
nnoremap <buffer> <Up> gk
nnoremap <buffer> <Down> gj
nnoremap <Down> gj
nnoremap <Up> gk
inoremap <buffer> <Up> <C-O>gk
inoremap <buffer> <Down> <C-O>gj
vnoremap <buffer> <Up> gk
vnoremap <buffer> <Down> gj
nnoremap <buffer>j gj
nnoremap <buffer>k gk
"}}}
" Copy and paste from X11 clipboard {{{
" http://vim.wikia.com/wiki/GNU/Linux_clipboard_copy/paste_with_xclip
" Requires xclip to be installed first
" Usage: select texts from Visual mode and press Ctrl+c to copy
" and Ctrl+v to paste (will disable default Visual Block mapping)
vmap <C-c> :!xclip -f -sel clip<CR>
map <C-v> mz:-1r !xclip -o -sel clip<CR>`z
"}}}
" AUTOCOMMANDS GO HERE
" Automatically re source vimrc when changes are done {{{
augroup autosource
au!
au BufWritePost .vimrc source ~/.vimrc
augroup END
" }}}
" Language specific default formatting for certain filetypes/file extentions. {{{
" http://dougblack.io/words/a-good-vimrc.html
augroup configgroup
autocmd!
autocmd VimEnter * highlight clear SignColumn
autocmd BufWritePre *.php,*.py,*.js,*.txt,*.hs,*.java,*.md
\:call <SID>StripTrailingWhitespaces()
autocmd FileType java setlocal noexpandtab
autocmd FileType java setlocal list
autocmd FileType java setlocal listchars=tab:+\ ,eol:-
autocmd FileType java setlocal formatprg=par\ -w80\ -T4
autocmd FileType php setlocal expandtab
autocmd FileType php setlocal list
autocmd FileType php setlocal listchars=tab:+\ ,eol:-
autocmd FileType php setlocal formatprg=par\ -w80\ -T4
autocmd FileType ruby setlocal tabstop=2
autocmd FileType ruby setlocal shiftwidth=2
autocmd FileType ruby setlocal softtabstop=2
autocmd FileType ruby setlocal commentstring=#\ %s
autocmd FileType python setlocal commentstring=#\ %s
autocmd BufEnter *.cls setlocal filetype=java
autocmd BufEnter *.zsh-theme setlocal filetype=zsh
autocmd BufEnter Makefile setlocal noexpandtab
autocmd BufEnter *.sh setlocal tabstop=2
autocmd BufEnter *.sh setlocal shiftwidth=2
autocmd BufEnter *.sh setlocal softtabstop=2
augroup END
" }}}