-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.vimrc
226 lines (197 loc) · 7.42 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
let g:is_unix=1
"Set shell to be ksh
set shell=ksh
source /home/$LOGNAME/.vim/bundles.vim
" encoding dectection
set fileencodings=utf-8,gb2312,gb18030,gbk,ucs-bom,cp936,latin1
" enable filetype dectection and ft specific plugin/indent
filetype plugin indent on
" enable syntax hightlight and completion
syntax on
"--------
" Vim UI
"--------
" color scheme
set background=dark
"color solarized
let g:hybrid_use_Xresources = 1
colorscheme hybrid
" highlight current line
au WinLeave * set nocursorline nocursorcolumn
au WinEnter * set cursorline cursorcolumn
set cursorline cursorcolumn
" Toggle fold
nnoremap <space> za
" Folding
set foldignore= " don't ignore anything when folding
set foldlevelstart=99 " no folds closed on open
set foldmethod=marker " collapse code using markers
set foldnestmax=1 " limit max folds for indent and syntax methods
" Folding rules
autocmd FileType c,cpp setlocal foldmethod=syntax foldnestmax=5
" editor settings
set viminfo=
set history=0
set nocompatible
set nofoldenable " disable folding"
set confirm " prompt when existing from an unsaved file
set backspace=indent,eol,start " More powerful backspacing
set t_Co=256 " Explicitly tell vim that the terminal has 256 colors "
set mouse=a " use mouse in all modes
set report=0 " always report number of lines changed "
set nowrap " dont wrap lines
set scrolloff=5 " 5 lines above/below cursor when scrolling
set number " show line numbers
set showmatch " show matching bracket (briefly jump)
set showcmd " show typed command in status bar
set title " show file in titlebar
set laststatus=2 " use 2 lines for the status bar
set matchtime=2 " show matching bracket for 0.2 seconds
set matchpairs+=<:> " specially for html
" set relativenumber
" Default Indentation
set autoindent
set smartindent " indent when
set tabstop=4 " tab width
set softtabstop=4 " backspace
set shiftwidth=4 " indent width
set textwidth=78
" set smarttab
set expandtab " expand tab to space
autocmd FileType php setlocal tabstop=2 shiftwidth=2 softtabstop=2 textwidth=120
autocmd FileType ruby setlocal tabstop=2 shiftwidth=2 softtabstop=2 textwidth=120
autocmd FileType php setlocal tabstop=4 shiftwidth=4 softtabstop=4 textwidth=120
autocmd FileType coffee,javascript setlocal tabstop=2 shiftwidth=2 softtabstop=2 textwidth=120
autocmd FileType python setlocal tabstop=4 shiftwidth=4 softtabstop=4 textwidth=120
autocmd FileType html,htmldjango,xhtml,haml setlocal tabstop=2 shiftwidth=2 softtabstop=2 textwidth=0
autocmd FileType sass,scss,css setlocal tabstop=2 shiftwidth=2 softtabstop=2 textwidth=120
" For all text files set 'textwidth' to 78 characters.
autocmd FileType text setlocal textwidth=78
" tabbar
let g:Tb_MaxSize = 2
let g:Tb_TabWrap = 1
" easy-motion
let g:EasyMotion_leader_key = '<Leader>'
" Tagbar
let g:tagbar_left=1
let g:tagbar_width=30
let g:tagbar_autofocus = 1
let g:tagbar_sort = 0
let g:tagbar_compact = 1
" tag for coffee
if executable('coffeetags')
let g:tagbar_type_coffee = {
\ 'ctagsbin' : 'coffeetags',
\ 'ctagsargs' : '',
\ 'kinds' : [
\ 'f:functions',
\ 'o:object',
\ ],
\ 'sro' : ".",
\ 'kind2scope' : {
\ 'f' : 'object',
\ 'o' : 'object',
\ }
\ }
let g:tagbar_type_markdown = {
\ 'ctagstype' : 'markdown',
\ 'sort' : 0,
\ 'kinds' : [
\ 'h:sections'
\ ]
\ }
endif
" Nerd Tree
let NERDChristmasTree=0
let NERDTreeWinSize=30
let NERDTreeChDirMode=2
let NERDTreeIgnore=['\~$', '\.pyc$', '\.swp$']
" let NERDTreeSortOrder=['^__\.py$', '\/$', '*', '\.swp$', '\~$']
let NERDTreeShowBookmarks=1
let NERDTreeWinPos = "right"
" ZenCoding
let g:user_emmet_expandabbr_key='<C-j>'
" Enable omni completion.
autocmd FileType python setlocal omnifunc=pythoncomplete#Complete
autocmd FileType c setlocal omnifunc=ccomplete#Complete
if !exists('g:neocomplcache_omni_patterns')
let g:neocomplcache_omni_patterns = {}
endif
let g:neocomplcache_omni_patterns.erlang = '[a-zA-Z]\|:'
" SuperTab
" let g:SuperTabDefultCompletionType='context'
let g:SuperTabDefaultCompletionType = '<C-X><C-U>'
let g:SuperTabRetainCompletionType=2
" ctrlp
set wildignore+=*/tmp/*,*.so,*.o,*.a,*.obj,*.swp,*.zip,*.pyc,*.pyo,*.class,.DS_Store " MacOSX/Linux
let g:ctrlp_custom_ignore = '\.git$\|\.hg$\|\.svn$'
" Keybindings for plugin toggle
nnoremap <F2> :set invpaste paste?<CR>
set pastetoggle=<F2>
nmap <F5> :TagbarToggle<cr>
nmap <F6> :NERDTreeToggle<cr>
nnoremap <leader>v V`]
"------------------
" Useful Functions
"------------------
" easier navigation between split windows
nnoremap <c-j> <c-w>j
nnoremap <c-k> <c-w>k
nnoremap <c-h> <c-w>h
nnoremap <c-l> <c-w>l
" When editing a file, always jump to the last cursor position
autocmd BufReadPost *
\ if ! exists("g:leave_my_cursor_position_alone") |
\ if line("'\"") > 0 && line ("'\"") <= line("$") |
\ exe "normal g'\"" |
\ endif |
\ endif
" w!! to sudo & write a file
cmap w!! %!sudo tee >/dev/null %
" Quickly edit/reload the vimrc file
nmap <silent> <leader>ev :e $MYVIMRC<CR>
nmap <silent> <leader>sv :so $MYVIMRC<CR>
" eggcache vim
nnoremap ; :
:command W w
:command WQ wq
:command Wq wq
:command Q q
:command Qa qa
:command QA qa
" for macvim
if has("gui_running")
set go=aAce " remove toolbar
set guicursor=a:block-blinkon0
"set transparency=30
set guifont=Spleen\ 16
set showtabline=2
set columns=140
set lines=40
endif
" => .sh, SetTitle
autocmd BufNewFile *.sh exec ":call SetTitle()"
"
func SetTitle()
if &filetype == 'sh'
call setline(1, "#!/bin/sh")
call append(line(".")+0, "#########################################################################")
call append(line(".")+1, "# Author: D5Nch3ck, (https://github.com/D5Nch3ck)")
call append(line(".")+2, "# E-mail: echo ZDVuY2gzY2tAZGlzcm9vdC5vcmcK | openssl enc -base64 -d")
call append(line(".")+3, "# Created: ".strftime("%F T %H:%M"))
call append(line(".")+4, "# Revision: none")
call append(line(".")+5, "# FileName: ".expand("%"))
call append(line(".")+6, "#########################################################################")
call append(line(".")+7, "")
endif
endfunc
" Append modeline after last line in buffer.
" Use substitute() instead of printf() to handle '%%s' modeline in LaTeX
" files.
function! AppendModeline()
let l:modeline = printf(" vim: set ts=%d sw=%d tw=%d ff=%s ft=%s %set :",
\&tabstop, &shiftwidth, &textwidth, &fileformat, &filetype, &expandtab ? '' : 'no')
let l:modeline = substitute(&commentstring, "%s", l:modeline, "")
call append(line("$"), l:modeline)
endfunction
nnoremap <silent> <Leader>ml :call AppendModeline()<CR>