forked from scrooloose/vimfiles
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathvimrc.improve
217 lines (171 loc) · 5.48 KB
/
vimrc.improve
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
set t_Co=256
source ~/.vim/vimrc
source ~/.vim/taglistrc
colorscheme railscasts
set noautochdir
set nolist
set wrap
set nu
set sts=2
set sw=2
"let g:fuzzy_ignore = "gems/*"
" ctags
set tags=~/.vim/tags,./tags;
" font
set guifont=DejaVu\ Sans\ Mono\ 10
" encoding
set fenc=utf-8
set fencs=utf-8,usc-bom,euc-jp,gb18030,gbk,gb2312,cp936
set enc=utf-8
let &termencoding=&encoding
"Set to auto read when a file is changed from the outside
set autoread
"Set mapleader
let mapleader = ","
let g:mapleader = ","
"Fast reloading of the .vimrc
nmap <leader>ss :source ~/.vimrc<CR>
"Fast editing of .vimrc
nmap <leader>sm :e ~/.vimrc<CR>
"Quick visit quickfix list
nmap <leader>fn :cn<CR>
nmap <leader>fp :cp<CR>
nmap <leader>fw :cw<CR>
"Quick visit buffer list
nmap <leader>bw :bw<CR>
nmap <leader>bn :bn<CR>
nmap <leader>bp :bp<CR>
"Surround
nmap <leader><leader> ysiw
nmap <leader>bw :bw<CR>
au BufNewFile,BufRead *.mxml set filetype=mxml
au BufNewFile,BufRead *.as set filetype=actionscript
"Vertical split then hop to new buffer
noremap <leader>sv :vsp^M^W^W<CR>
noremap <leader>sh :split^M^W^W<CR>
"map to fuzzy finder text mate stylez
nnoremap <silent> <c-f> :FufCoverageFile<CR>
nnoremap <leader>ff :FufTaggedFile<CR>
nnoremap <leader>ft :FufTag<CR>
nnoremap <leader>fj :FufJumpList<CR>
nnoremap <leader>fl :FufLine<CR>
nnoremap <leader>fr :FufRenewCache<CR>
nnoremap <leader>p viw"0p<CR>
nnoremap <leader>P V"0p<CR>
nnoremap <leader>al z30l
nnoremap <leader>ah z30h
nnoremap <leader>sg :args **/*.rb<CR>:argdo 0<CR>
nnoremap <leader>sa :vim /<C-R><C-W>/j **/*
nnoremap <leader>sr :vim /<C-R><C-W>/j **/*.rb<CR>
"map to bufexplorer
nnoremap <C-B> :BufExplorer<cr>
" Mappings
" ********************************************************************
" Professor VIM says '87% of users prefer jj over Esc', jj abrams strongly disagrees
imap jj <Esc>
imap uu _
imap hh =>
imap ;; <ESC>A;
imap {{ <ESC>A{
autocmd FileType ruby,eruby imap aa @
autocmd FileType php imap kk ->
autocmd FileType python imap :: <ESC>A :
" Python dict
let g:pydiction_location = '~/.vim/ftplugin/pydiction/complete-dict'
"for C -- http://vim.wikia.com/wiki/Delete_C_Function
map <silent><leader>df 0d/{<Enter>daB
"for Ruby
map <silent><leader>dd ?def <Enter>d%
map <silent><leader>di ?if <Enter>d%
"for PHP
map <silent><leader>dp ?function <Enter>0d}
" Inser New Line
" **************************************************************
"nmap <S-Enter> O<Esc>
"nmap <Enter> o<Esc>
" do not insert a comment leader after an enter, (no work, fix!!)
set fo-=r
" Cursor Movement
" *************************************************************
" Make cursor move by visual lines instead of file lines (when wrapping)
nmap <up> gk
nmap <down> gj
" PHP
" *************************************************************
nmap <leader>cp :w<CR>:!php -l %<CR>
"let phplinkrule_check=system("file ~/.vim/phplinkrule")
"let phpri=stridx(phplinkrule_check, "ERROR")
"if phpri == -1
" source ~/.vim/phplinkrule
" function! PHP_FireFox()
" let localpath=getcwd()."/".expand("%")
" let filepath=PHP_ParseLink(localpath)
" silent execute "!firefox"." ".filepath
" endfunction
" map <leader>rp :call PHP_FireFox()<CR>
"end
" -----------------------------------------------------------------------------
" " | Pluggins |
" "
" -----------------------------------------------------------------------------
" NERDTree
"********************************************************************
noremap <leader>n :NERDTreeToggle<CR>
" User instead of Netrw when doing an edit /foobar
let NERDTreeHijackNetrw=1
" Single click for everything
let NERDTreeMouseMode=1
" Avoid map conflict to NERD commenter
let VCSCommandMapPrefix="<leader>v"
" Taglist
noremap <leader>t :TlistToggle<CR>
let Tlist_Ctags_Cmd="/usr/bin/ctags"
"Paste toggle - when pasting something in, don't indent.
set pastetoggle=<F2>
nnoremap ; :
" Easy window navigation
nmap <C-h> <C-w>h
nmap <C-j> <C-w>j
nmap <C-k> <C-w>k
nmap <C-l> <C-w>l
nmap <silent> ,/ :nohlsearch<CR>
cmap w!! w !sudo tee % >/dev/null
" Omni Completion
" *************************************************************
autocmd FileType html set omnifunc=htmlcomplete#CompleteTags
autocmd FileType python set omnifunc=pythoncomplete#Complete
autocmd FileType javascript set omnifunc=javascriptcomplete#CompleteJS
autocmd FileType css set omnifunc=csscomplete#CompleteCSS
autocmd FileType xml set omnifunc=xmlcomplete#CompleteTags
autocmd FileType php set omnifunc=phpcomplete#CompletePHP
autocmd FileType c set omnifunc=ccomplete#Complete
autocmd FileType cpp set omnifunc=cppcomplete#Complete
autocmd FileType ruby,eruby set omnifunc=rubycomplete#Complete
set expandtab
set cindent
set smartindent
set autoindent
set tabstop=4 shiftwidth=4 softtabstop=4
autocmd FileType ruby,eruby set tabstop=2 shiftwidth=2 softtabstop=2
autocmd FileType python,python set tabstop=4 shiftwidth=4 softtabstop=4
inoremap <S-Enter> <Esc>O
inoremap <C-Enter> <Esc>o
inoremap <expr> <Esc> pumvisible()?"\<C-e>":"\<Esc>"
inoremap <expr> <C-J> pumvisible()?"\<PageDown>\<C-N>\<C-P>":"\<C-X>\<C-O>"
inoremap <expr> <C-K> pumvisible()?"\<PageUp>\<C-P>\<C-N>":"\<C-K>"
inoremap <C-]> <C-X><C-]>
" for convenience in insert mode
inoremap ( ()<ESC>i
inoremap ) <c-r>=ClosePair(')')<CR>
inoremap { {}<ESC>i
inoremap } <c-r>=ClosePair('}')<CR>
inoremap [ []<ESC>i
inoremap ] <c-r>=ClosePair(']')<CR>
function! ClosePair(char)
if getline('.')[col('.') - 1] == a:char
return "\<Right>"
else
return a:char
endif
endf
set dir=/tmp