forked from DxCx/WorkEnv
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvimrc.vim
223 lines (181 loc) · 4.92 KB
/
vimrc.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
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
" Use FWSlash instead of backslash
set shellslash
" first set runtimepath to this directory.
let &runtimepath.=','.escape(expand('<sfile>:p:h'), '\,')
" Setup Pathogen
runtime pathogen/autoload/pathogen.vim
call pathogen#infect('bundle/{}')
call pathogen#helptags()
" set filetype stuff on
filetype on
filetype plugin on
filetype plugin indent on
" Enable syntax highlight
syntax enable
" Color Scheme Solorized Dark
let g:solarized_termcolors=256
colorscheme solarized
set background=dark
" Forget being compatible with good ol' vi
" and enable hidden buffers support
set nocompatible
set hidden
" Ident settings
filetype indent on
set tabstop=4
set shiftwidth=4
set autoindent " always auto indent
set copyindent " copy indent from privius line
set smarttab " insert tabs according to shiftwidth
" No ~ or swap files.
set nobackup
set noswapfile
" Show Line numbers
set nu
" set the search scan to wrap lines
" and ignore case, but recognize upper case
set wrap
set linebreak
set nolist
set wrapscan
set ignorecase
set smartcase
" add $ at the end of replace instead of just delete it.
set cpoptions=ces$
" AutoComplete Setup:
" . = current buffer
" w = buffers from other windows
" b = buffers loaded in the buffer list
" k = files from the directory
" d = include defines
" i = includes
" tag complition
set complete=.,w,b,k,d,i,t
" Cool complete menu
set wildmenu
" Search options (search as you type + highlight)
set hlsearch
set incsearch
" I Want vim to remember as much as he can
set history=1000
set undolevels=1000
" don't autocomplete to match those file types
set wildignore=*.swp,*.bak,*.pyc,*.class
" I Want leader key to be , and not \
let mapleader=","
" Set region to English
set spelllang=en_us
" Python specific settings
autocmd filetype python set expandtab " Use spaces and not real tabs
" coffee specific settings
autocmd BufNewFile,BufReadPost *.coffee setl foldmethod=indent nofoldenable
function! CmdRun(str)
exe a:str
endfunction
let my_grep_base="."
function! CmdLine(str)
exe "menu Foo.Bar :" . a:str
emenu Foo.Bar
unmenu Foo
endfunction
function! GrepCursor()
exe "normal! viw"
call VisualSelection("vimgrep")
endfunction
function! VisualSelection(direction) range
let l:saved_reg = @"
execute "normal! vgvy"
let l:pattern = escape(@", '\\/.*$^~[]')
let l:pattern = substitute(l:pattern, "\n$", "", "")
if a:direction == 'b'
execute "normal ?" . l:pattern . "^M"
elseif a:direction == 'vimgrep'
" call CmdLine("vimgrep " . '/'. l:pattern . '/ ' . g:my_grep_base . '/**/*.[ch]')
call CmdRun("vimgrep " . '/'. l:pattern . '/ ' . g:my_grep_base . '/**/*.[ch]')
exe "ccl"
exe "cwindow"
elseif a:direction == 'replace'
call CmdLine("%s" . '/'. l:pattern . '/')
elseif a:direction == 'f'
execute "normal /" . l:pattern . "^M"
endif
let @/ = l:pattern
let @" = l:saved_reg
endfunction
" custom Bindings
map <silent> <F2> :NERDTreeToggle<CR>
vmap <silent> <leader>g :call VisualSelection('vimgrep')<CR>
nmap <silent> <leader>g :call GrepCursor()<CR>
nmap <silent> <leader>s :set spell!<CR>
" Switch to alternate file
nmap <silent> <F5> :make<CR>
nmap <silent> <C-l> :bnext<CR>
nmap <silent> <C-h> :bprevious<CR>
" Fugitive's Autocmds.
autocmd BufReadPost fugitive://* set bufhidden=delete
" remove Trailing spaces on ,<space>
nmap <silent> <leader><space> mzgg=G`z<CR>:w<CR>:%s/\\s\\+$//g<CR>:w<CR>
" Set xptemplate to more convinent key
let g:xptemplate_key = '<Tab>'
" Status Bar
set laststatus=2
set t_Co=256 " 256 Colors!
let g:airline_powerline_fonts=1
let g:airline_theme='murmur'
let g:airline_section_x=""
let g:airline_section_y="%{strlen(&ft)?&ft:'none'}:%{&ff}"
let g:airline_right_sep=''
" Allow overrides via ~/.vim/vimrc.local
if filereadable(expand("~/.vim/vimrc.local"))
source ~/.vim/vimrc.local
endif
" CtrlP
nmap <silent> <leader>f :CtrlP<CR>
" Mako template syntax:
au BufNewFile,BufRead *.tmpl set filetype=mako
" EasyMotion
let g:EasyMotion_do_mapping=0
map w <Plug>(easymotion-w)
map W <Plug>(easymotion-W)
map e <Plug>(easymotion-e)
map E <Plug>(easymotion-E)
map b <Plug>(easymotion-b)
map B <Plug>(easymotion-B)
" map f <Plug>(easymotion-f)
" map F <Plug>(easymotion-F)
" map t <Plug>(easymotion-t)
" map T <Plug>(easymotion-T)
" Gundo Mapping
map <silent> <F3> :GundoToggle<CR>
" Relative numbering
set relativenumber
map <silent> - :set relativenumber!<CR>
" Mapping F8 to change to Hex View
noremap <F8> :call HexMe()<CR>
let $in_hex=0
function HexMe()
set binary
set noeol
if $in_hex>0
:%!xxd -r
let $in_hex=0
else
:%!xxd
let $in_hex=1
endif
endfunction
" Enable Hardmode :) (Disabled at the moment until relative will work)
" Until issue resolve, No arrow keys
map <Up> <NOP>
map <Down> <NOP>
map <Left> <NOP>
map <Right> <NOP>
imap <Up> <NOP>
imap <Down> <NOP>
imap <Left> <NOP>
imap <Right> <NOP>
vmap <Up> <NOP>
vmap <Down> <NOP>
vmap <Left> <NOP>
vmap <Right> <NOP>
"autocmd VimEnter,BufNewFile,BufReadPost * silent! call HardMode()