root/dotfiles/vim/kiske-vimrc @ 29507

Revision 7285, 10.8 kB (checked in by kiske, 5 years ago)

dotfiles/screen/kiske-screenrc,
dotfiles/vim/kiske-vimrc,
dotfile/zsh/kiske-zshrc: imported

Line 
1" .vimrc by Tobias Schlitt <toby@php.net>.
2" No copyright, feel free to use this, as you like, as long as you keep some
3" credits.
4"
5" General VIM settings file. Optimized for coding PHP can be found in
6" ~/vim/ftdetect/php.vim.
7"
8" v1.1pl1
9"
10" Changelog:
11"
12" v1.1:
13" --------------
14"  - Added versioning and changelog
15"  - Added auto-completion using <TAB>
16"  - Added auto-reload command, when .vimrc changes
17"  - Deactivated <CTRL>-p => "pear package" in favor of
18"  - Mapped <CTRL>-p => "run through CLI"
19"  - Added fold markers for better overview
20"  - Added for mapping for wrapping visual selections into chars (like '/(/...)
21"  - Added scrolljump=5 and scrolloff=3 for better moving around with folds
22"  - Added mapping <CTRL>-h to search for the word under the cursor (should be
23"    a funcion) using phpm
24"  - Replaced map/imap with noremap/inoremap for clearer mappings
25"
26" v1.1pl1:
27" --------------
28"  - Fixed issue with <CTRL>-p for running PHP CLI (missing <cr>)
29"  - Remapped PHP compile check to ; (in command mode only)
30"
31" v1.2:
32" -----
33"  - Remapped PHP compile check to . (in command mode only)
34"  - Mapped ; to (add ; at the end of line, when missing - command mode only)
35"  - Added make facilities (:make, jump to error).
36"  - Added setting for not highlighting every search result (nohlsearch).
37"  - Added laststatus=2 (tipp by Derick)
38"  - Tip by Jakob (UG): Visual, <z>, <f> == foldmarkers for area
39"  - Moved PHP specific settings to .vim/ftdetect/php.vim
40"  - Activated sourcing of ftplugins
41"  - Added file type setting for .phps files
42"  - Created PDV (phpDocumentor for VIM) and added mapping (ATTENTION! BC
43"    break!)
44"  - Fixed bug with cover char mapping of "" in visual mode
45"  - Added possible alternatives for other coding standards
46"
47"  - Replace grepprg to remove SVN results
48"  - Add mapping for VIM7 spell checks to <F5>
49"  - Added autocommand to highlight the current line in insert mode.
50"  - Added skeleton file to be read for new PHP files.
51
52" Source local settings
53"source ~/.vimlocalrc
54
55" Colorschema
56colorscheme inkpot
57
58" Set new grep command, which ignores SVN!
59" TODO: Add this to SVN
60set grepprg=/usr/bin/vimgrep\ $*\ /dev/null
61
62" Map <F5> to turn spelling on (VIM 7.0+)
63map <F5> :setlocal spell! spelllang=en_us<cr>
64
65" Highlight current line in insert mode.
66"autocmd InsertLeave * se nocul
67"autocmd InsertEnter * se cul
68
69" Reads the skeleton php file
70" Note: The normal command afterwards deletes an ugly pending line and moves
71" the cursor to the middle of the file.
72autocmd BufNewFile *.php 0r ~/.vim/skeleton.php | normal Gdd
73
74" ChangeLog
75let g:changelog_dateformat = "%Y-%m-%d"
76let g:changelog_username = "<Tomohiro Mitsumune>"
77
78" {{{ .phps files handled like .php
79
80au BufRead,BufNewFile *.phps            set filetype=php
81
82" }}}
83
84" {{{  Settings   
85
86if has("autocmd") && exists("+omnifunc")
87    autocmd FileType php        :set omnifunc=phpcomplete#CompletePHP
88    autocmd FileType html       :set omnifunc=htmlcomplete#CompleteTags
89    autocmd FileType python     :set omnifunc=pythoncomplete#Complete
90    autocmd FileType javascript :set omnifunc=javascriptcomplete#CompleteJS
91    autocmd FileType xml        :set omnifunc=xmlcomplete#CompleteTags
92    autocmd FileType css        :set omnifunc=csscomplete#CompleteCSS
93    autocmd FileType c          :set omnifunc=ccomplete#Complete
94    autocmd Filetype *
95                \   if &omnifunc == "" |
96                \           setlocal omnifunc=syntaxcomplete#Complete |
97                \   endif
98endif
99
100" Use filetype plugins, e.g. for PHP
101syntax on
102filetype plugin on
103
104" Show nice info in ruler
105set ruler
106set laststatus=2
107
108" Set standard setting for PEAR coding standards
109set expandtab
110set tabstop=4
111set softtabstop=4
112set shiftwidth=4
113
114" Show line numbers by default
115set nonumber
116
117" Enable folding by fold markers
118set foldmethod=marker
119
120" Autoclose folds, when moving out of them
121set foldclose=all
122
123" don`t Use incremental searching
124"検索文字列入力時に順次対象文字列にヒットさせない
125set noincsearch
126
127" Do not highlight search results
128"検索結果文字列のハイライトを有効にしない
129set nohlsearch
130
131" Jump 5 lines when running out of the screen
132set scrolljump=5
133
134" Indicate jump out of the screen when 3 lines before end of the screen
135set scrolloff=3
136
137" Repair wired terminal/vim settings
138set backspace=start,eol,indent
139
140" Allow file inline modelines to provide settings
141set modeline
142
143" minibufexplの設定
144let g:miniBufExplMapWindowNavVim = 1
145let g:miniBufExplSplitBelow=0  " Put new window above
146let g:miniBufExplMapWindowNavArrows = 1
147let g:miniBufExplMapCTabSwitchBufs = 1
148let g:miniBufExplModSelTarget = 1
149let g:miniBufExplSplitToEdge=1
150
151" Use Vim defaults instead of 100% vi compatibility
152set nocompatible
153
154"スマートインデント
155set smartindent
156
157"検索文字列に大文字が含まれている場合は区別して検索する
158set smartcase
159
160"検索時に最後まで行ったら最初に戻る
161set wrapscan
162
163"タブの左側にカーソル表示
164"set listchars=tab:\\
165set nolist
166
167"入力中のコマンドをステータスに表示
168set showcmd
169
170"括弧入力時の対応する括弧を表示
171set showmatch
172
173function! GetB()
174  let c = matchstr(getline('.'), '.', col('.') - 1)
175  let c = iconv(c, &enc, &fenc)
176  return String2Hex(c)
177endfunction
178" :help eval-examples
179" The function Nr2Hex() returns the Hex string of a number.
180func! Nr2Hex(nr)
181  let n = a:nr
182  let r = ""
183  while n
184    let r = '0123456789ABCDEF'[n % 16] . r
185    let n = n / 16
186  endwhile
187  return r
188endfunc
189" The function String2Hex() converts each character in a string to a two
190" character Hex string.
191func! String2Hex(str)
192  let out = ''
193  let ix = 0
194  while ix < strlen(a:str)
195    let out = out . Nr2Hex(char2nr(a:str[ix]))
196    let ix = ix + 1
197  endwhile
198  return out
199endfunc
200
201"ステータスラインに文字コードと改行文字を表示する
202" set statusline=%<[%n]%m%r%h%w%{'['.(&fenc!=''?&fenc:&enc).':'.&ff.']['.&ft.']'}\ %F%=%l,%c%V%8P
203if winwidth(0) >= 120
204  set statusline=%<[%n]%m%r%h%w%{'['.(&fenc!=''?&fenc:&enc).':'.&ff.']'}%y\ %F%=[%{GetB()}]\ %l,%c%V%8P
205else
206  set statusline=%<[%n]%m%r%h%w%{'['.(&fenc!=''?&fenc:&enc).':'.&ff.']'}%y\ %f%=[%{GetB()}]\ %l,%c%V%8P
207endif
208"set statusline=%{GetB()}
209
210"code2html
211let html_use_css = 1
212
213" コマンドライン補完するときに強化されたものを使う(参照 :help wildmenu)
214" set wildmenu
215" コマンドライン補間をシェルっぽく
216set wildmode=list:longest
217" バッファが編集中でもその他のファイルを開けるように
218set hidden
219" 外部のエディタで編集中のファイルが変更されたら自動で読み直す
220set autoread
221
222""set termencoding=utf-8
223""set encoding=utf-8
224""set fileencoding=utf-8
225""set fileencodings=utf-8,cp932
226
227" 文字コードの自動認識
228if &encoding !=# 'utf-8'
229  set encoding=japan
230  set fileencoding=japan
231endif
232if has('iconv')
233  let s:enc_euc = 'euc-jp'
234  let s:enc_jis = 'iso-2022-jp'
235  " iconvがeucJP-msに対応しているかをチェック
236  if iconv("\x87\x64\x87\x6a", 'cp932', 'eucjp-ms') ==# "\xad\xc5\xad\xcb"
237    let s:enc_euc = 'eucjp-ms'
238    let s:enc_jis = 'iso-2022-jp-3'
239  " iconvがJISX0213に対応しているかをチェック
240  elseif iconv("\x87\x64\x87\x6a", 'cp932', 'euc-jisx0213') ==# "\xad\xc5\xad\xcb"
241    let s:enc_euc = 'euc-jisx0213'
242    let s:enc_jis = 'iso-2022-jp-3'
243  endif
244  " fileencodingsを構築
245  if &encoding ==# 'utf-8'
246    let s:fileencodings_default = &fileencodings
247    if has('unix')
248        let &fileencodings = s:enc_jis .','. s:enc_euc
249        let &fileencodings = &fileencodings .','. s:fileencodings_default
250    else
251        let &fileencodings = s:enc_jis .','. s:enc_euc .',cp932'
252        let &fileencodings = &fileencodings .','. s:fileencodings_default
253    endif
254    unlet s:fileencodings_default
255  else
256    let &fileencodings = &fileencodings .','. s:enc_jis
257    set fileencodings+=utf-8,ucs-2le,ucs-2
258    if &encoding =~# '^\(euc-jp\|euc-jisx0213\|eucjp-ms\)$'
259      set fileencodings+=cp932
260      set fileencodings-=euc-jp
261      set fileencodings-=euc-jisx0213
262      set fileencodings-=eucjp-ms
263      let &encoding = s:enc_euc
264      let &fileencoding = s:enc_euc
265    else
266      let &fileencodings = &fileencodings .','. s:enc_euc
267    endif
268  endif
269  " 定数を処分
270  unlet s:enc_euc
271  unlet s:enc_jis
272endif
273" 日本語を含まない場合は fileencoding に encoding を使うようにする
274if has('autocmd')
275  function! AU_ReCheck_FENC()
276    if &fileencoding =~# 'iso-2022-jp' && search("[^\x01-\x7e]", 'n') == 0
277      let &fileencoding=&encoding
278    endif
279  endfunction
280  autocmd BufReadPost * call AU_ReCheck_FENC()
281endif
282" 改行コードの自動認識
283set fileformats=unix,dos,mac
284" □とか○の文字があってもカーソル位置がずれないようにする
285if exists('&ambiwidth')
286  set ambiwidth=double
287endif
288
289
290" cvs,svnの時は文字コードをutf-8に設定
291autocmd FileType cvs :set fileencoding=utf-8
292autocmd FileType svn :set fileencoding=utf-8
293
294" set tags
295if has("autochdir")
296  set autochdir
297  set tags=tags
298else
299  set tags=./tags,./../tags,./*/tags,./../../tags,./../../../tags,./../../../../tags,./../../../../../tags
300endif
301nnoremap <silent> <F8> :TlistToggle<CR>
302set tags+=~/.vim/systags
303set tags+=~/.vim/symfony.tags
304set tags+=~/.vim/jquery.tags
305
306" command mode 時 tcsh風のキーバインドに
307cmap <C-A> <Home>
308cmap <C-F> <Right>
309cmap <C-B> <Left>
310cmap <C-D> <Delete>
311cmap <Esc>b <S-Left>
312cmap <Esc>f <S-Right>
313
314" cedit
315set cedit=<C-O>
316
317"表示行単位で行移動する
318nmap j gj
319nmap k gk
320vmap j gj
321vmap k gk
322
323" 前回終了したカーソル行に移動
324autocmd BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$") | exe "normal g`\"" | endif
325
326",e でそのコマンドを実行
327nmap ,e :execute '!' &ft ' %'<CR>
328
329" SeeTab
330let g:SeeTabCtermFG="black"
331let g:SeeTabCtermBG="red"
332
333" netrw-ftp
334let g:netrw_ftp_cmd="netkit-ftp"
335
336" netrw-http
337let g:netrw_http_cmd="wget -q -O"
338
339" YankRing.vim
340nmap ,y :YRShow<CR>
341
342" html escape function
343:function HtmlEscape()
344silent s/&/\&amp;/eg
345silent s/</\&lt;/eg
346silent s/>/\&gt;/eg
347:endfunction
348
349:function HtmlUnEscape()
350silent s/&lt;/</eg
351silent s/&gt;/>/eg
352silent s/&amp;/\&/eg
353:endfunction
354
355" 補完候補の色づけ for vim7
356hi Pmenu ctermbg=8
357hi PmenuSel ctermbg=12
358hi PmenuSbar ctermbg=10
359
360" 256色
361set t_Co=256
362set t_Sf=[3%dm
363set t_Sb=[4%dm
364
365" encoding
366nmap ,U :set encoding=utf-8<CR>
367nmap ,E :set encoding=euc-jp<CR>
368nmap ,S :set encoding=cp932<CR>
369
370" closetag
371"autocmd FileType html,xml,xsl,php  :source ~/.vim/scripts/closetag.vim
372
373"Omni補完のキー割り当て変更
374inoremap <C-F> <C-X><C-O>
375
376" paste/nopaste
377nmap ep :set paste<CR>
378nmap enp :set nopaste<CR>
379
380" fuzzyfinder
381nmap <silent> eff :FuzzyFinderFile<CR>
382nmap <silent> efv :FuzzyFinderFavFile<CR>
383nmap <silent> efm :FuzzyFinderMruFile<CR>
384nmap <silent> efc :FuzzyFinderMruCmd<CR>
385nmap <silent> efd :FuzzyFinderDir<CR>
386nmap <silent> efa :FuzzyFinderAddFavFile<CR>
387nmap <silent> eft :FuzzyFinderTag<CR>
388nmap <silent> efb :FuzzyFinderBuffer<CR>
389
390" }}}
391
Note: See TracBrowser for help on using the browser.