Skip to content

Instantly share code, notes, and snippets.

@c9s c9s/.gvimrc
Created Nov 3, 2017

Embed
What would you like to do?
" vim:fdm=marker:et:fdl=0:
"
" Author: Yo-An Lin <yoanlin93 {at} gmail.com>
" URL: http://c9s.blogspot.com/
"
" Font {{{
" set gfn=Dejavu\ Sans\ Mono\ 9
" set gfn=Andale\ Mono:h14
":set guifont=Screen15,\ 7x13,font\\,with\\,commas
if has('gui_mac')
"set gfn=Monaco:h14
"set gfn=Inconsolata\ 11
"set gfn=ProggyCleanTT\ CE\ 12
"set gfn=ProggyCleanTT_CE:h16
"set gfn=ProggySquareTT\ 12
"set gfn=Crisp\ 12
elseif has('gui_gtk2')
set gfn=Bitstream\ Vera\ Sans\ Mono\ 10
elseif has('gui_win32')
"set gfn=Consolas\ 10
endif
" }}}
" GUI Options {{{
"gimrLtlcM
set guioptions+=c
set guioptions-=e
set guioptions-=T
set guioptions-=m
set guioptions-=r
set guioptions-=l
set guioptions-=L
"set mouseshape+=n:beam,v:beam,s:beam,i:beam
"set mousemodel=extend
"set guipty
"set guicursor+=n-v-c:ver50-cursor-blinkwait300-blinkon90-blinkoff90
" set guicursor=n-v-c:ver25-Cursor/lCursor
" set guicursor+=i:block-cursor-blinkwait200-blinkon110-blinkoff110
" set guicursor+=v:ver90-cursor-blinkwait200-blinkon150-blinkoff150
" set cursorline
" }}}
" cursorline tuning {{{
if &background == 'dark'
"hi cursorline guibg=#161616
else
"hi cursorline guibg=#dedede
endif
" }}}
" MacVim only {{{
" set antialias
" if exists('&macatsui')
" set nomacatsui
" endif
" }}}
"set guifont=-misc-fixed-medium-r-normal--10-100-75-75-c-60-iso8859-1
" default window size
winsize 90 60
winpos 555 0
" colorscheme solarized
color ir_black
" vim:fdm=marker:sw=2:ts=2:et:fdl=0:fileencoding=utf-8:
"============================
" Date: 日 1/ 1 18:58:10 2012
" Version: 10.9
"============================
" general settings
set nocompatible " must be the first line
filetype off
set rtp+=~/.vim
" load from vundle
set rtp+=~/.vim/bundle/vundle/
set rtp+=~/.vim/bundle/bufexplorer
set rtp+=~/.vim/bundle/gocode
call vundle#begin()
Plugin 'L9'
Plugin 'wavded/vim-stylus'
Plugin 'mbbill/undotree'
Plugin 'c9s/hypergit.vim'
Plugin 'c9s/cpan.vim'
Plugin 'c9s/phpunit.vim'
Plugin 'lumiliet/vim-twig'
Plugin 'duganchen/vim-soy'
Plugin 'int3/vim-extradite'
Plugin 'easymotion/vim-easymotion'
Plugin 'mileszs/ack.vim'
Plugin 'rhysd/conflict-marker.vim'
Plugin 'leafgarland/typescript-vim'
Plugin 'godlygeek/tabular'
Plugin 'mattn/webapi-vim'
Plugin 'gmarik/vundle'
Plugin 'tpope/vim-fugitive'
Plugin 'tpope/vim-speeddating'
Plugin 'tpope/vim-unimpaired'
Plugin 'msanders/cocoa.vim'
Plugin 'ntpeters/vim-better-whitespace'
Plugin 'scrooloose/nerdtree'
Plugin 'solars/github-vim'
Plugin 'mattn/gist-vim'
Plugin 'vim-scripts/indent-motion'
Plugin 'eagletmt/neco-ghc'
" Plugin 'corntrace/bufexplorer'
Plugin 'c9s/vim-phpunit'
Plugin 'c9s/perlomni.vim'
Plugin 'kana/vim-fakeclip'
Plugin 'shawncplus/phpcomplete.vim'
Plugin 'tpope/vim-surround'
Plugin 'pangloss/vim-javascript'
Plugin 'Align'
Plugin 'Shougo/vimproc'
Plugin 'Shougo/vimshell.vim'
Plugin 'Shougo/neocomplete.vim'
Plugin 'c9s/emoticon.vim'
Plugin 'majutsushi/tagbar'
" Plugin 'kien/ctrlp.vim'
Plugin 'vim-scripts/sudo.vim'
" Plugin 'Lokaltog/vim-powerline'
Plugin 'vim-scripts/FuzzyFinder'
Plugin 'nathanaelkane/vim-indent-guides'
" Plugin 'tpope/vim-markdown'
Plugin 'c9s/vim-markdown-php'
Plugin 'kchmck/vim-coffee-script'
Plugin 'rafaelfranca/rtf_pygmentize'
" Plugin 'jaxbot/github-issues.vim'
Plugin 'mattn/emmet-vim'
Plugin 'fatih/vim-go'
" Plugin 'dgryski/vim-godef'
Plugin 'cakebaker/scss-syntax.vim'
" Plugin 'vim-scripts/genutils'
" Plugin 'msanders/snipmate.vim'
" Plugin 'drmingdrmer/xptemplate'
" Plugin 'Shougo/unite.vim'
" Plugin 'stephpy/vim-php-cs-fixer'
call vundle#end()
filetype plugin indent on
" let g:Powerline_symbols = 'unicode'
" zencoding configuration
let g:user_zen_leader_key = '<C-z>'
" behave xterm
syntax on
filetype on
filetype plugin indent on " required!
set expandtab
" include plugins
" set rtp+=~/.vimexts/xptemplate/
" set rtp+=/path/to/blah
set sidescroll=1
set sidescrolloff=3
set showfulltag showmatch showcmd showmode
set textwidth=0
set noerrorbells
set ambiwidth=double
set formatoptions=tcroqnlM1
" set formatlistpat&
" let &formatlistpat .= '\|^\s*[*+-]\s*'
" Allow switching edited buffers without saving
" set hidden
"set timeoutlen=300
set winaltkeys=no showtabline=2 hlsearch
set nolazyredraw
" set cursorline
set guioptions+=M " no system menu
"set mouse=a
"behave mswin
set viewdir=~/.vim-view
" options ================================================= {{{
"set cedit=<C-y>
"nm : q:i
"nm / q/i
"nm ? q?i
"set mps+==:;
"set title titlestring=%<%F%=%l/%L-%P titlelen=70
"set title titlestring=%<%F titlelen=70
fun! s:find_bin(bin)
let paths = split(expand('$PATH'),':')
for p in paths
if filereadable( p . '/' . a:bin )
return p . '/' . a:bin
endif
endfor
return
endf
" set shell automatically
let shells = [ 'zsh' , 'bash' , 'sh' ]
" while ! exists('&shell') && len(shells) > 0
" while len(shells) > 0
" let sh = remove(shells,0)
" let path = s:find_bin(sh)
" if strlen(path) > 0
" exec 'set shell='.path
" endif
" endwhile
set shell=/opt/local/bin/zsh
"set previewwindow
set previewheight=9
"set winheight=7
"set winminheight=3
" set autowrite
" numbers of colo
" set t_Co=256
" scroll jump && scroll off
set sj=1 so=3
"nnoremap <C-E> <C-E><C-E><C-E><C-E>
"nnoremap <C-Y> <C-Y><C-Y><C-Y><C-Y>
set tags+=~/.tags
set dict+=~/vim_completion
"set thesaurus=
"setlocal spell spelllang=en_US
"If you want to put swap files in a fixed place, put a command resembling the
"following ones in your .vimrc
" set dir=~/tmp
set noswapfile
"(for MS-DOS and Win32)
"set dir=c:\\tmp
"set wildmode=full,list
"set wildmode=list:full
set wildmenu
set wildmode=longest,list
set wildignore+=*.o,*.a,*.so,*.obj,*.lib,*.ncb,*.opt,*.plg,.svn,.git,*.lo,*.la,*.in
" set wildoptions
" statusline format
set statusline=%<%f\ %h%m%r%=%k[%{(&fenc==\"\")?&enc:&fenc}%{(&bomb?\",bom\":\"\")}]\ %-14.(%l,%c%v%)\ %p
"com! DefaultStatusLine set statusline=%<%f\ %h%m%r%=%k[%{(&fenc==\"\")?&enc:&fenc}%{(&bomb?\",bom\":\"\")}]\ %-14.(%l,%c%v%)\ %p
"com! DefaultStatusLine set statusline=%<%f\ %h%m%r%=%k[%{(&fenc==\"\")?&enc:&fenc}%{(&bomb?\",bom\":\"\")}]\ %-14.(%l,%c%)\ %p
" scrollbind
"set scb
" history
set history=500
set shiftround smarttab showcmd noerrorbells nocompatible number expandtab
set sw=4 ts=4 sts=4
" no error bell,visual bell
" set novb
set modeline
set mat=15
set maxmem=10096
set noignorecase
" current is no smartcase for command line completion ignorecase
"set smartcase
set ruler incsearch nowrap autoindent smartindent showmatch bs=indent,eol,start
set ff=unix
"set wm=6
" encoding
" set fileencodings=utf-8,big5,gbk,sjis,euc-jp,euc-kr,utf-bom,iso8859-1
set fenc=utf-8
" set fencs=utf-8,utf-16le,big5,euc-jp,utf-bom,iso8859-1,utf-16le
" set fencs=ucs-bom,big5,utf-8,euc-jp,utf-bom,iso8859-1,utf-16le
" set fencs=shift-jis,big5,euc-jp,utf-8,utf-16le
" set fencs=utf-8,big5,euc-jp,utf-bom,iso8859-1,utf-16le
set fileencodings=ucs-bom,utf-8,euc-jp,big-5,sjis,default
set enc=utf-8
set tenc=utf-8
" =========================================================== }}}
" fold options ============================================ {{{
"set fdt=FoldText()
set nofoldenable
set vop=folds,cursor
" set fdc=2 " fdc: fold column
set fdn=2 " fdn: fold nest max
set fdl=3 " fdl: fold level
" set fml=3 " fml: fold min line
" set fdm=marker
" set fdm=manual
"
" }}}
" fold text {{{
fu! FoldText()
let line = getline(v:foldstart)
let cms = &commentstring
" make pattern
let cms = substitute( cms , '%s' , '|' , 'g' )
let cms = substitute( cms , '[*<!>]' , '\\\0' , 'g' )
let cms = '\v(' . cms
if cms =~ '|$'
else
let cms .= '|'
en
let cms .= '\{\{\{\d=)'
" for debug
"let g:test = cms
" strip commentstring
if line =~ cms
let sub = substitute( line, cms , '', 'g')
" strip prefix
elseif line =~ '^\v(sub|template)\s'
let sub = substitute( line, '^\v(sub|template)\s''?(\w+)''?.*','\1: \2','')
elseif line =~ '^\v\=(\w+)\s'
let sub = substitute( line, '^\v\=(\w+)\s(\w+)','\1: \2','')
else
let sub = line
en
" strip space
let sub = substitute( sub, '^\s*' , '', 'g')
let sub = substitute( sub, '\s*$' , '', 'g')
" count line
let num = v:foldend - v:foldstart
" make format line
let fline = printf( "|%3d|- %s " , v:foldend - v:foldstart ,sub )
"return fold
retu v:folddashes . v:folddashes . v:folddashes . fline
endf
" }}}
" skeleton ================================================ {{{
" au bufnewfile *.c 0r ~/.vim/skeleton/template.c
" au bufnewfile *.cpp 0r ~/.vim/skeleton/template.cpp
" au bufnewfile *.h 0r ~/.vim/skeleton/template.h
" au bufnewfile *.java 0r ~/.vim/skeleton/template.java
" au bufnewfile *.sh 0r ~/.vim/skeleton/template.sh
" au bufnewfile *.css 0r ~/.vim/skeleton/template.css
" au bufnewfile *.html 0r ~/.vim/template/html/template.html
" au bufnewfile *.s 0r ~/.vim/skeleton/template.s
" =========================================================== }}}
" autocommand ============================================= {{{
" make view ( save folds , tabs , cursor position )
" au bufwinleave *.c,*.pm,*.pl,*.t,*.cpp silent mkview
" autocmd BufWinLeave *.* silent mkview
fun! s:EnableView()
augroup UpdateView
au!
autocmd! BufWritePost *.* silent mkview
autocmd! BufReadPost *.* silent loadview
augroup END
endf
com! EnableView :cal s:EnableView()
com! DisableView :au! UpdateView
let s:enable_view = 1
if s:enable_view
cal s:EnableView()
endif
" autocmd BufWinLeave [a-z] silent mkview
" autocmd BufWinEnter [a-z] silent loadview
" :autocmd BufRead * set tw=79 nocin ic infercase fo=2croq
"autocmd bufread,bufnewfile *.txt :set textwidth=80
"au bufwritepost ~/.vimrc source ~/.vimrc
" =========================================================== }}}
" mapping "{{{
" make tab in v mode indent code"{{{
nnoremap <tab> v>
nnoremap <s-tab> v<
xnoremap <unique> <tab> >gv
xnoremap <unique> <s-tab> <gv
"}}}
" paste mass text
set pastetoggle=<F1>
" highlight search toggle
nmap <silent> <C-h> :set hlsearch!<CR>
" time stamp
im <F2> <c-r>=strftime("%c")<CR>
" insertion
" im <C-i>d <c-r>=strftime("%c")<CR>
" im <C-i>
" window resize mapping "{{{
nm <a-x> <c-w><c-w><c-w>_
nm <a-=> <c-w>=
nn <c-w>9 8<c-w>+
nn <c-w>0 8<c-w>-
"}}}
" Bash-like command mapping ================================= "{{{
cnoremap <c-a> <home>
cnoremap <c-e> <end>
cnoremap <c-b> <left>
cnoremap <c-d> <del>
cnoremap <c-f> <right>
cnoremap <C-_> <c-f>
cnoremap <c-n> <down>
cnoremap <c-p> <up>
cnoremap <C-*> <c-a>
if has('gui_running')
language mes en_US
" lang en
set langmenu=en_US.utf-8
endif
"}}}
" change assign"{{{
nm cr= ^f=cf;
nm cl= ^f=c^
"}}}
" change ( sp1 , sp2 , var3 , spl )
"nmc s
nm gp1 0f(lvf,h
nm gp2 0f(f,lvf,h
nm gp3 0f(f,;lvf,h
nm gp0 0f(lvi(
nm gpl 0f)hvf,l
"nm <f2> :w<cr>
"nm <f3> :q<cr>
nm <f4> ggvg"+y''
nm dt f<vf>f>d
"nm <c-k>mx :!chmod u+x %<cr>
"nm <c-k>sh :sh<cr>
"nm <c-k>mf [{v]}zf
"nm <c-k>mh :tohtml<cr>:w %:r.html<cr>:q<cr>
nm =b {=}''
fun! MakeExecutable(file)
cal system("chmod +x " . a:file)
exec 'edit! ' . a:file
endf
com! -nargs=0 MakeExecutableCurrent :cal MakeExecutable( expand('%') )
com! -nargs=1 MakeExecutable :cal MakeExecutable( <args> )
" hate ';'
"nn ; :
nn q; q:i
nn q/ q/i
"}}}
com! DisableIndent :set noautoindent nocindent nosmartindent
" commands
" grep pattern in this file
" com! -nargs=* VG :vimgrep <args> %
com! -complete=file -nargs=* G :grep <args>
" convert <arrow {{{
com! -range -nargs=0 ConvertArrow :cal s:ConvertArrow(<line1>,<line2>)
cabbr carrow ConvertArrow
fu! s:ConvertArrow(s,e)
silent! exec a:s . ',' . a:e . 's/</\&lt;/g'
silent! exec a:s . ',' . a:e . 's/>/\&gt;/g'
endf
" }}}
" buffer sel by pattern {{{
fu! BufSel(pattern)
let buf_count = bufnr("$")
let cur_bufnr = 1
let nummatches = 0
let firstmatchingbufnr = 0
while cur_bufnr <= buf_count
if(bufexists(cur_bufnr))
let currbufname = bufname(cur_bufnr)
if(match(currbufname, a:pattern) > -1)
echo cur_bufnr . ": ". bufname(cur_bufnr)
let nummatches += 1
let firstmatchingbufnr = cur_bufnr
endif
endif
let cur_bufnr = cur_bufnr + 1
endwhile
if(nummatches == 1)
execute ":buffer ". firstmatchingbufnr
elseif(nummatches > 1)
let desiredbufnr = input("Enter buffer number: ")
if(strlen(desiredbufnr) != 0)
execute ":buffer ". desiredbufnr
endif
else
echo "No matching buffers"
endif
endf
fu! BufSelInput()
let pattern = input( "pattern: " )
call BufSel( pattern )
endf
"Bind the BufSel() function to a user-command
com! -nargs=1 Bs :call BufSel("<args>")
nmap <leader>bf :call BufSelInput()<CR>
"}}}
" blogger template"{{{
" ctrl-f5
fu! GetColorCode()
let name = input( "name:" )
let desp = input( "description:" )
"let line = getline(".")
sil! exec 'silent! s/\(#[0-9a-f]\{3,6\}\)\(.\{-}$\)/$'.name.' \2\r'
\ . '<variable name="'.name.'" '
\ . 'description="'.desp.'" \r\t\t'
\ . 'type="color" default="\1" value="\1">\r'
\ . '/'
sil exec "normal vkkx"
sil exec "/\\v<b:skin><![cdata["
sil exec "normal p"
endf
" nm <c-f5> :cal Getcolorcode()<cr>
fu! GetBtFold() " blogger template fold
if getline(v:lnum) =~ '\v\<(b:widget|b:includable|b:section|b:skin).{-}(\/)@<!\>'
retu 'a1'
elsei getline(v:lnum) =~ '\v\<\/(b:widget|b:includable|b:section|b:skin)\>'
retu 's1'
el
retu "="
en
endf
setlocal foldexpr=GetBtFold()
"}}}
"
" Space commands {{{ all space command : expand tab to space.
com! -nargs=0 AllSpace :setlocal et | retab!
cabbr allspace AllSpace
" }}}
" Trim Space {{{
com! -range TrimSpace :setlocal nohls | :silent <line1>,<line2>s!\s*$!!g
cabbr trimspace TrimSpace
" }}}
" Find file "{{{
fu! Find(name)
let l:list=system("find . -name '".a:name."' | perl -ne 'print \"$.\\t$_\"'")
let l:num=strlen(substitute(l:list, "[^\n]", "", "g"))
if l:num < 1
echo "'".a:name."' not found"
return
endif
if l:num != 1
echo l:list
let l:input=input("Which ? (CR=nothing)\n")
if strlen(l:input)==0
return
endif
if strlen(substitute(l:input, "[0-9]", "", "g"))>0
echo "Not a number"
return
endif
if l:input<1 || l:input>l:num
echo "Out of range"
return
endif
let l:line=matchstr("\n".l:list, "\n".l:input."\t[^\n]*")
else
let l:line=l:list
endif
let l:line=substitute(l:line, "^[^\t]*\t./", "", "")
execute ":e ".l:line
endf
com! -nargs=1 Find :call Find("<args>")
"}}}
" VimGrep {{{
" XXX: deprecated? orz
fun! Vimgrep()
cal inputsave()
let g:mypattern = input("pattern(vimgrep):")
if strlen( g:mypattern ) == 0
" do nothing
else
exec ':vimgrep "' . g:mypattern . '" * '
en
cal inputrestore()
endf
"nnoremap .gr :vimgrep *<left><left>
nn ,gr :cal Vimgrep()<cr>
" }}}
" QuickFix window toggle"{{{
com! -bang -nargs=? QFix cal QFixToggle(<bang>0)
fu! QFixToggle(forced)
if exists("g:qfix_win") && a:forced == 0
cclose
unlet g:qfix_win
else
copen 10
let g:qfix_win = bufnr("$")
en
endf
nn <silent> <leader>q :QFix<cr>
""}}}
" Gist plugin cabbr {{{
" cabbr gist Gist
" }}}
" ==== FILE SPECIFIED OPTIONS ===============================
fun! s:setup_exec_cmd()
let cmd = input("cmd:",'','file')
return cmd
endf
fun! s:run_exe()
if ! exists('g:exec_cmd')
let g:exec_cmd = s:setup_exec_cmd()
endif
echo "Executing.."
exec '! clear && ' . g:exec_cmd
echo "Done"
endf
fun! s:init_c()
let c_comment_strings=1
set path+=/usr/local/include/js/
set path+=/opt/local/include/cairo/
set path+=/opt/local/include/glib-2.0/
com! RunExe :cal s:run_exe()
nmap <C-c><C-c> :make<CR>
nmap <C-c><C-x> :RunExe<CR>
setlocal cindent
setlocal fdm=syntax
ab #d #define
ab #i #include
setlocal equalprg=indent
endf
fu! s:init_cpp()
let c_comment_strings=1
set ep=indent
nm <F7> :make<CR>
"au bufread,bufnewfile *.cpp nm <c-f7> :!g++ -wall % -o %:r.out<cr>
"au bufread,bufnewfile *.cpp :set makeprg=g++\ -wall\ %\ -o\ %:r.out
endf
" Filetype Rc Autocmd {{{
augroup FiletypeRC
au!
au Filetype c :cal s:init_c()
au Filetype cpp :cal s:init_cpp()
au Filetype css :cal s:init_css()
au Filetype perl :cal s:init_perl()
au Filetype xul :0r ~/.vim/skeleton/template.xul
au Filetype php :cal s:init_php()
au Filetype vim :cal s:init_vim()
augroup END
"}}}
fun! s:init_php()
setlocal si
let php_sql_query = 1
let php_htmlInStrings = 1
let php_baselib = 1
let php_special_functions = 1
endf
" vim script helpers ========================================
" bind load key for vim script file
fun! s:init_vim()
com! SearchCamelCaseFunctions /\<\([A-Z][a-z]*\)*(.*)
com! TranslateNamingStyle :cal s:TranslateNamingStyle()
setlocal sw=2
" nmap <buffer> <F6> :so %<CR>
" nmap <buffer> ,s :so %<CR>
" select vim function
nmap sf ?^fu\%[nction]!?\s\+<CR>V/^endf\%[unction]<CR>
endf
" XXX translate naming style {{{
fun! s:TranslateNamingStyle()
let word = expand('<cword>')
normal ciw
put=word
endf
" }}}
" perl template
" au BufNewFile *.pl :0r ~/.vim/skeleton/template.pl
" au BufNewFile *.pm :0r ~/.vim/skeleton/template.pm
" au BufNewFile *.tt :0r ~/.vim/skeleton/template.tt
au BufNewFile *.t :0r ~/.vim/skeleton/template.t
cabbr iamperl IamPerl
com! IamPerl :call s:i_am_perl()
fu! s:i_am_perl()
setf perl
cal s:init_perl()
endf
fun! SyncWindowFunction()
cal search('^sub ','b')
let line = getline('.')
let func = matchstr( line , '\(^sub\s\+\)\@<=\w\+')
normal zt
wincmd w
cal search('^sub\s\+' . func )
normal zt
endf
fun! s:perl_test_growl(file)
redraw
echo "Test Running..."
cal system( 'perl -Ilib ' . a:file . ' 2>&1 | growlnotify -t Perl &' )
endf
com! PerlTestThis :cal s:perl_test_growl( expand('%') )
fun! s:init_perl()
"check perl code with :make
set makeprg=perl\ -c\ %\ $*
set errorformat=%f:%l:%m
"iabbr w warn
"iabbr p print
"iabbr end __END__
" iabbr pkg __PACKAGE__
"iabbr $s_ $self
"iabbr $c_ $class
iabbr _perl #!/usr/bin/env perl
iabbr _s $self->
iabbr _pkg package
" set tt2 as html
"au BufRead,BufNewFile *.tt2 :setfiletype html
" syntax tuning.
let perl_include_pod = 1
let perl_extended_vars = 0
let perl_want_scope_in_variables = 1
let perl_fold = 1
let perl_fold_blocks = 1
" jifty syntax
let jifty_fold_schema = 1
let jifty_fold_schema_column = 1
let jifty_fold_template = 1
let jifty_fold_tags = 1
let jifty_fold_dispatcher = 1
" run perl code
" nmap <C-c><C-c> :!perl %<CR>
" syntax check
" nmap <C-c><C-y> :!perl -c %<CR>
nmap <buffer> <silent> <C-c><C-c> :make<CR>
nnoremap <silent><buffer> [[ m':call search('^\s*sub\>', "bW")<CR>
vnoremap <silent><buffer> [[ m':<C-U>exe "normal! gv"<Bar>call search('^\s*sub\>', "bW")<CR>
nnoremap <silent><buffer> ]] m':call search('^\s*sub\>', "W")<CR>
vnoremap <silent><buffer> ]] m':<C-U>exe "normal! gv"<Bar>call search('^\s*sub\>', "W")<CR>
nnoremap <silent><buffer> ss :cal SyncWindowFunction()<CR>
" Data::Dumper Helper
nmap <buffer> <leader>dd Iuse<Space>Data::Dumper;warn<Space>Dumper(<ESC>A);<ESC>
setlocal equalprg=perltidy
setlocal fdm=syntax
setlocal fdc=2 fdn=2 fdl=2
" fdl: fold level
" fdn: fold nest max
" fdc: fold column
" set fml=3 " fml: fold min line
"set fdm=manual
" indentexpr , indent-expression , XXX read from <cWORD>
"set fde=GetPerlFold()
endf
fun! s:perl_test_rc()
" nmap <silent> <C-c><C-c> :!clear && perl -Ilib %<CR>
nmap <buffer> <silent> <C-c><C-c> :PerlTestThis<CR>
endf
autocmd BufReadPost *.t :cal s:perl_test_rc()
" mason filetype
autocmd BufReadPost,BufNew *.mt :setlocal filetype=mason
" quick visual select
imap <C-v><C-v> <ESC>v
"
"=============================================================
" PLUGIN SETTING
"=============================================================
" ctags for windows
if has("win32")
let Tlist_ctags_cmd = $vimruntime . '/ctags/ctags.exe'
endif
" taglist {{{
let tlist_compact_format=1
let tlist_display_prototype=1
"nmap <leader>t :TlistToggle<cr>
" }}}
" nerd tree explorer"{{{
nmap <silent> <leader>e :NERDTreeToggle<CR>
nmap <silent> <leader>nf :NERDTreeFind<CR>
nmap <silent> <leader>nm :NERDTreeMirror<CR>
cabbr ntf NERDTreeFind
cabbr ntm NERDTreeMirror
"}}}
" mru recent file list {{{
let MRU_Auto_Close = 0
let MRU_Use_Current_Window = 1
let MRU_Max_Entries = 20
"}}}
"
" Mac Custom tabpage key for mac and other platform {{{
" window size key for macbook
if ( has('gui_mac') || has('gui_macvim') ) && has('gui_running')
nmap <silent> <D--> :resize -5<CR>
nmap <silent> <D-=> :resize +5<CR>
nmap <silent> <D-]> :vertical resize +5<CR>
nmap <silent> <D-[> :vertical resize -5<CR>
nmap <silent> <D-\> <C-w><C-w>
" nmap <c-x>tf :tabfind
" nmap <c-x>th :tab help<CR>
nmap <D-s> :w<CR>
endif
" }}}
" nmap <C-t><C-e> :tabedit
" nmap <C-t><C-f> :tabfind
nm <c-n> gt
nm <c-p> gT
nmap te :tabedit
nmap ts :tabedit %
" CPAN ChangeLogs {{{
map <buffer> ,w /p5-([^/]+)/<CR> "vyaW
nmap <F12> ,w /^Changes:<CR> Ahttp://search.cpan.org/dist/<C-R>v<ESC> :1<CR> :/dist/[^/]+/p5<CR> :. s,dist/[^/]+/p5-,dist/,<CR> :. s,Makefile,Changes,<CR>
" }}}
" Scrollbind {{{
fun! BindScroll()
set scrollbind!
wincmd w
set scrollbind!
syncbind
endf
com! BindScroll :cal BindScroll()
nnoremap <C-x><C-b> :BindScroll
" }}}
nm <M-n> :m .+1<cr>
nm <M-p> :m .-2<cr>
"
if has('gui_running')
"hi CursorLine gui=underline guibg=NONE
set nocursorline
" Show popup menu if right click.
set mousemodel=popup
" Don't focus the window when the mouse pointer is moved.
set nomousefocus
" Hide mouse pointer on insert mode.
set mousehide
endif
" Terminal HighLight Config {{{
fun! s:PmenuCyan()
hi Pmenu ctermfg=black ctermbg=cyan
hi PmenuSel ctermfg=black ctermbg=red
hi PmenuSbar ctermbg=black ctermfg=cyan
endf
if ! has('gui_running')
if &term == 'xterm-color'
set t_Co=16
elseif &term == 'xterm-color256'
set t_Co=256
endif
cal s:PmenuCyan()
"hi WildMenu ctermbg=Red ctermfg=
"hi ModeMsg ctermbg=green ctermfg=black
hi ModeMsg ctermbg=green ctermfg=black
hi Statement ctermfg=darkgreen
hi Comment ctermfg=gray ctermbg=darkblue
" hi Comment ctermbg=darkgreen ctermfg=black
hi IncSearch ctermfg=black ctermbg=darkred
hi Search ctermfg=black ctermbg=darkgreen
hi LineNr ctermbg=black ctermfg=green
hi Folded ctermbg=darkgreen ctermfg=black
" hi FoldColumn ctermbg=black ctermfg=green
hi FoldColumn ctermbg=black ctermfg=darkblue
hi TabLineFill ctermfg=black
hi TabLine ctermfg=darkgreen ctermbg=black
hi TabLineSel ctermbg=darkgreen ctermfg=black
hi Cursor ctermbg=darkgreen
hi VertSplit ctermbg=black ctermfg=black
hi StatusLine ctermfg=darkgreen
hi StatusLineNC ctermfg=black ctermbg=darkgreen
hi Visual ctermbg=green ctermfg=black
hi NonText ctermfg=darkgreen
" hi Normal ctermfg=blue
hi Directory ctermfg=green
" Gui HighLigth Config
else
hi CursorLine guibg=#111111
endif
" }}}
" SVK plugin
au BufNewFile,BufRead svk-commit*.tmp setf svk
" Find Sub
" command! FindSub :call Find_Sub()
fu! Find_Sub(pattern)
"XXX: can not use
"exec ":!grep -rP -o '(?<=sub )\s*\w+' " + expand('%')
endf
com! Sublist :!grep -rP -o '(?<=sub )\s*\w+' %
"
" CSS Comment Helpers "{{{
fun! s:init_css()
"imap <buffer> <C-c>c /* */<ESC>hhhi
"imap <buffer> <C-c>l /***********************/<CR>
"imap <buffer> <C-c>[ /*<CR>
imap <buffer> <C-c>] <CR>*/<CR>
vmap <buffer> +c <Esc>`<i/* <Esc>`>a */<Esc>
vmap <buffer> -c <Esc>`<xxx<Esc>`>axxx<Esc>
endf
" "}}}
" Option Mode =============================
fun! ToggleFoldColumn()
if &fdc == 0
exec 'set fdc=' . g:default_fdc
else
let g:default_fdc = &fdc
set fdc=0
endif
endf
fun! OptionValue(opt)
let v = input(a:opt . ':','')
exec 'set ' . a:opt . '=' . v
endf
fun! OptionToggle(opt)
exec 'set ' . a:opt . '!'
redraw
exec printf('echo "option (%s):" . &%s',a:opt,a:opt)
endf
fun! s:optionmode_toggle()
redraw
if g:optionmode
silent mapclear <buffer>
echohl WarningMsg | "Option Mode Off" | echohl None
else
nmap <silent> <buffer> <c-f> :cal ToggleFoldColumn()<CR>
nmap <silent> <buffer> <c-p> :cal OptionToggle('paste')<CR>
nmap <silent> <buffer> <c-s> :cal OptionToggle('smartcase')<CR>
nmap <silent> <buffer> <c-l> :cal OptionToggle('number')<CR>
echohl WarningMsg | "Option Mode On" | echohl None
endif
let g:optionmode = g:optionmode ? 0 : 1
endf
let g:optionmode = 0
com! OptionModeToggle :cal s:optionmode_toggle()
" nm <silent> <leader>k :OptionModeToggle<CR>
fun! s:VimComplete(findstart, base)
if a:findstart
let line = getline('.')
let start = col('.') - 1
while start > 0 && line[start - 1] =~ '\a'
let start -= 1
endwhile
return start
else
let b:lcontext = getline('.')
if b:lcontext =~ '^\s*com'
elseif b:lcontext =~ '^\s*fun'
elseif b:lcontext =~ '^\s*let'
elseif b:autocmd =~ '^\s*auto'
else " statement completion
endif
return res
endif
endfun
" set completefunc=VimComplete
" vmap = :retab!<CR>
" au bufnewfile *.xul :0r ~/.vim/skeleton/template.xul
autocmd BufRead *.json :setf javascript
" open tag in new tab
nm g+ yiw:tab tag <C-R>"<CR>
" Fold Help "{{{
" display a block only (fold other) ( just use zx )
" zE: erase all folds
" `< : jump to the start of a visual block
" `> : jump to the end of a visual block
" ma : bookmark the position into register a
" mb : bookmark the position into register b
" k : upper
" V : enter visual line mode
" gg : go to the top of a file
" zf : make fold"}}}
" Pod Helpers
"
" Pod outline helper
" just read template from file
fu! PodHelperOutline()
let lines = readfile( expand("~/template.pod") )
:call append( 0 , lines )
endf
"
fun! EvalVimScriptRegion(s,e)
let lines = getline(a:s,a:e)
let file = tempname()
cal writefile(lines,file)
redir @e
silent exec ':source '.file
cal delete(file)
redraw
redir END
echo "Region evaluated."
if strlen(getreg('e')) > 0
10new
redraw
silent file "EvalResult"
setlocal noswapfile buftype=nofile bufhidden=wipe
setlocal nobuflisted nowrap cursorline nonumber fdc=0
" syntax init
set filetype="eval"
syn match ErrorLine +^E\d\+:.*$+
hi link ErrorLine Error
silent $put =@e
endif
endf
augroup VimEval
au!
au filetype vim :command! -range Eval :cal EvalVimScriptRegion(<line1>,<line2>)
au filetype vim :vnoremap <silent> e :Eval<CR>
augroup END
fun! RenameFromSearchConfirm()
let s = getreg('/')
let sub = input("replace:")
if strlen(sub) == 0
return
endif
exec '%s!' . s . '!' . sub . '!gc'
endf
fun! RenameFromSearch()
let s = getreg('/')
let sub = input("replace '".s."':")
if strlen(sub) == 0
return
endif
exec '%s!' . s . '!' . sub . '!g'
endf
fun! s:rename_all()
let s = expand('<cword>')
let sub = input("replace '".s."':")
if strlen(sub) == 0
return
endif
exec ':bufdo :%s!\<' . s . '\>!' . sub . '!g'
endf
fun! RenameWord(w)
let s = expand('<cword>')
exec ':%s!\<' . s . '\>!' . a:w . '!g'
endf
fun! RenameRange(s,e)
let from = input("replace:")
let sub = input("replace '\\<".a:ndl."\\>':")
if strlen(sub) == 0
return
endif
exec printf('%d,%ds/\<%s\>/%s/gc',a:s,a:e,from,sub)
endf
com! -narg=1 -range RN :cal RenameRange(<line1>,<line2>)
com! -narg=1 RNword :cal RenameWord(<q-args>)
com! RenameAll :cal s:rename_all()
com! RenameFromSearch :cal RenameFromSearch()
com! RenameFromSearchConfirm :cal RenameFromSearchConfirm()
" ===========================================================
" delete all unlisted buffer but left current one
fun! BufferClear()
let curbuffer = bufnr('%')
let lastbuffernr = last_buffer_nr()
let nr = 0
let deleted = 0
while nr <= lastbuffernr
if nr == curbuffer
let nr = nr + 1
continue
endif
if bufexists( nr ) && ! buflisted( nr )
exec nr . 'bw'
let deleted = deleted + 1
endif
let nr = nr + 1
endwhile
redraw
ls!
echo deleted . " buffer deleted!"
endf
com! BufferClear :call BufferClear()
" fold vim syntax
let g:vimsyn_folding = 'afp'
" open new file tab (abandon)
fun! OpenNewFileTab()
let x = input("OpenFile:","",'file')
if strlen(x) == 0
redraw
return
endif
exec 'tabedit ' . x
endf
" nmap <silent> <c-x><c-f> :call OpenNewFileTab()<CR>
" add prefix
fu! AddPrefix()
let s = expand('<cword>')
let prefix = input('prefix for "\<'.s.'\>":')
if strlen(prefix) == 0
echo 'canceled.'
return
endif
exec ':bufdo %s!\<' . s . '\>!' . prefix . s . '!g'
endf
command! AddPrefix :call AddPrefix()
nmap <C-x><lt> :AddPrefix<CR>
fun! DefineCommand(text,var)
let l:cmd = input(a:text)
if strlen(l:cmd) > 0
exec var . ' = ' . l:cmd
endif
endf
let g:make_command = ''
let g:run_command = ''
fun! DefineRunCommand()
let run_command = input("Define Run Command:")
if strlen(run_command) > 0
let g:run_command = run_command
endif
endf
com! DefineMakeCommand :call DefineCommand("Define Make Command:","g:make_command")
com! DefineRunCommand :call DefineCommand("Define Run Command:","g:run_command")
nmap <C-x>0 :exec "!clear && ".g:make_command<CR>
nmap <C-x>9 :exec "!clear && ".g:run_command<CR>
au filetype perl :let g:run_command = 'perl -Ilib ' . expand('%')
au BufReadPost *.xs :let g:make_command = 'perlmake > /dev/null'
au filetype perl :let g:make_command = 'perlmake > /dev/null'
" prevent completion conflict by autocomplpop when entering newline
fun! CompCheck()
if pumvisible()
return "\<ESC>o"
else
return "\<CR>"
endif
endf
inoremap <silent> <CR> <C-R>=CompCheck()<CR>
" autocmd! BufNewFile *.user.js 0r $HOME/.vim/template/greasemonkey.txt
let g:gist_clip_command = 'pbcopy'
" open lib and corresponding test at a new tab
command! -nargs=1 Lib call s:open_lib_and_corresponding_test(<f-args>)
" AlternateCommand lib Lib
fun! s:open_lib_and_corresponding_test(fname)
execute 'tabnew lib/' . a:fname . '.rb'
execute 'vnew test/' . a:fname . '_test.rb'
execute "normal \<Plug>(quickrun)\<C-w>J\<C-w>7_"
endf
"
" listcharsを切り替える
command! ListCharsDispFull set listchars=tab:^-,eol:$,trail:_,nbsp:% list
command! ListCharsDispTab set listchars=tab:^- list
command! ListCharsDispEol set listchars=eol:$ list
autocmd CmdwinEnter * AutoComplPopDisable
autocmd CmdwinLeave * AutoComplPopEnable
" set wrapscan " 検索時に最後まで行ったら最初に戻る
" set nobackup " バックアップファイルは作らない
" set autoread " 外部のエディタで編集中のファイルが変更されたら自動で読み直す
" surround.vim
" surroundに定義を追加する【ASCIIコードを調べるには:echo char2nr("-")】
" タグ系
let g:surround_33 = "<!-- \r -->"
let g:surround_37 = "<% \r %>"
let g:surround_45 = "<!-- \r -->"
"変数展開系
let g:surround_35 = "#{\r}"
let g:surround_36 = "${\r}"
let g:surround_64 = "@{\r}"
" fixme
fun! Smartchr(fallback_literal, ...)
let args = reverse(copy(a:000))
call add(args, a:fallback_literal)
let args = map(args, 'type(v:val) == type("") ? [0, v:val] : v:val')
for i in range(len(args) - 1)
let [pattern1, literal1] = args[i]
let [pattern2, literal2] = args[i+1]
if pattern1 is 0
if search('\V' . escape(literal2, '\') . '\%#', 'bcn')
return repeat("\<BS>", len(literal2)) . literal1
endif
else
throw 'FIXME: pattern is not implemented yet: ' . string(args[i])
endif
endfor
return a:fallback_literal
endf
" c programming
" setlocal tags+=/usr/include/tags,/usr/include/sys/tags
func! LContext()
let c = col(".")
let l = line(".")
let w = winline()
normal! L
if c == col(".") && l == line(".") && w == winline()
exe "normal! \<C-b>"
endif
endfunc
fun! BufInfo()
echo "[bufnr ] ".bufnr("%")
echo "[bufname ] ". expand("%:p")
echo "[cwd ] " . getcwd()
if filereadable(expand("%"))
echo "[mtime ] " . strftime("%Y-%m-%d %H:%M %a",getftime(expand("%")))
endif
echo "[size ] " . Bufsize() . " bytes"
echo "[comment ] " . (exists('b:commentSymbol') ? b:commentSymbol : "undefined")
echo "[filetype ] " . &ft
echo "[tab ] " . &ts . " (" . (&et ? "" : "no") . "expandtab)"
echo "[keywordprg] " . &keywordprg
echo "[makeprg ] " . &makeprg
echo "[Buffer local mappings]"
nmap <buffer>
endf
fun! FileInfo(filename)
let fn = expand(a:filename)
echo "[filename ] " . fn
echo "[type ] " . getftype(fn)
echo "[mtime ] " . strftime("%Y-%m-%d %H:%M %a",getftime(fn))
echo "[size ] " . getfsize(fn) . " bytes"
echo "[perm ] " . getfperm(fn)
endf
fun! Strip(str)
return substitute(a:str, '\%(^\s\+\|\s\+$\)', '', 'g')
endf
fun! LStrip(str)
return substitute(a:str, '^\s\+', '', 'g')
endf
fun! RStrip(str)
return substitute(a:str, '\s\+$', '', 'g')
endf
com! RTrim :s/\s*$//
com! LTrim :s/^\s*//
"smart home function
fun! SmartHome(mode)
let curcol = col(".")
if &wrap
normal! g^
else
normal! ^
endif
if col(".") == curcol
if &wrap
normal! g0
else
normal! 0
endif
endif
if a:mode == "v"
normal msgv`s
endif
return ""
endf
"smart end function
fun! SmartEnd(mode)
let curcol = col(".")
let lastcol = a:mode == "i" ? col("$") : col("$") - 1
"gravitate towards ending for wrapped lines
if curcol < lastcol - 1
call cursor(0, curcol + 1)
endif
if curcol < lastcol
if &wrap
normal g$
else
normal $
endif
else
normal g_
endif
"correct edit mode cursor position, put after current character
if a:mode == "i"
call cursor(0, col(".") + 1)
endif
if a:mode == "v"
normal msgv`s
endif
return ""
endf
" IncBufSwitch {{{
"-----------------------------------------------------------------------------
" IncBufSwitch
" - Emacs
" - C-c
"-----------------------------------------------------------------------------
if 1
command! IncBufSwitch :call IncBufferSwitch()
hi link IncBufSwitchCurrent Search
hi IncBufSwitchOnlyOne cterm=reverse ctermfg=1 ctermbg=6 cterm=bold
fun! PartialBufSwitch(partialName, first)
let lastBuffer = bufnr("$")
let g:ibs_buflist = ''
let flag = 0
let i = 1
while i <= lastBuffer
if (bufexists(i) != 0 && buflisted(i))
let filename = expand("#" . i . ":t")
if (match(filename, a:partialName) > -1)
if flag == g:ibs_tabStop
if a:first == 0
let g:ibs_current_buffer = i
endif
endif
let g:ibs_buflist = g:ibs_buflist .','. expand("#" . i . ":t")
let flag = flag + 1
endif
endif
let i = i + 1
endwhile
let g:ibs_buflist = substitute(g:ibs_buflist, '^,', '', '')
if flag == g:ibs_tabStop + 1
let g:ibs_tabStop = - 1
endif
return flag
endf
fun! IncBufferSwitch()
let origBufNr = bufnr("%")
let g:ibs_current_buffer = bufnr("%")
let partialBufName = ""
let g:ibs_tabStop = 0
let cnt = PartialBufSwitch('', 1)
echon "ibs: "
if cnt == 1
echon ' {'
echohl IncBufSwitchCurrent | echon g:ibs_buflist | echohl None
echon '}'
else
echon ' {'. g:ibs_buflist .'}'
endif
while 1
let flag = 0
let rawChar = getchar()
if rawChar == 13 " <CR>
exe "silent buffer " . g:ibs_current_buffer
break
endif
if rawChar == 27 || rawChar == 3 " <ESC> or <C-c>
"echon "\r "
let g:ibs_current_buffer = origBufNr
break
endif
if rawChar == "\<BS>"
let g:ibs_tabStop = 0
if strlen(partialBufName) > 0
let partialBufName = strpart(partialBufName, 0, strlen(partialBufName) - 1)
if strlen(partialBufName) == 0
let flag = 1
if bufnr("%") != origBufNr
let g:ibs_current_buffer = origBufNr
endif
endif
else
if bufnr("%") != origBufNr
let g:ibs_current_buffer = origBufNr
endif
break
endif
elseif rawChar == 9 " TAB -- find next matching buffer
let g:ibs_tabStop = (g:ibs_tabStop == -1) ? 0 : g:ibs_tabStop + 1
else
let nextChar = nr2char(rawChar)
let partialBufName = partialBufName . nextChar
endif
let matchcnt = PartialBufSwitch(partialBufName, flag)
if matchcnt == 0
let partialBufName = strpart(partialBufName, 0, strlen(partialBufName) - 1)
let matchcnt = PartialBufSwitch(partialBufName, flag)
endif
redraw
echon "\ribs: " . partialBufName
call ShowBuflist(partialBufName, matchcnt)
endwhile
endf
fun! ShowBuflist(partialName, matchcnt)
let lastBuffer = bufnr("$")
let i = 1
let first = 1
echon " {"
while i <= lastBuffer
if (bufexists(i) != 0 && buflisted(i))
let filename = expand("#" . i . ":t")
if (a:partialName != "" && match(filename, a:partialName) > -1)
if first
let first = 0
else
echon ","
endif
if (g:ibs_current_buffer == i)
if a:matchcnt == 1
echohl IncBufSwitchOnlyOne
else
echohl IncBufSwitchCurrent
endif
endif
echon filename
echohl None
endif
endif
let i = i + 1
endwhile
echon "}"
endf
endif
" }}}
" Rename Helper {{{
" Christian J. Robinson <infynity@onewest.net>
" http://www.vim.org/scripts/script.php?script_id=1928
command! -nargs=* -complete=file -bang RenameI :call RenameI("<args>", "<bang>")
fun! RenameI(name, bang)
let l:curfile = expand("%:p")
let v:errmsg = ""
silent! exe "saveas" . a:bang . " " . a:name
if v:errmsg =~# '^$\|^E329'
if expand("%:p") !=# l:curfile && filewritable(expand("%:p"))
silent exe "bwipe! " . l:curfile
if delete(l:curfile)
echoerr "Could not delete " . l:curfile
endif
endif
else
echoerr v:errmsg
endif
endf
" }}}
" Screen + GDB {{{
" screen + gdb ----------------------------------------------------
" sign define br text=>> texthl=Search
" command! Breakpoint call Breakpoint() | se nu
" command! ListBreakpoints sign place
" let g:bpmap = {}
" let g:bpsignplace = 0
" function! Breakpoint()
" let pos = expand("%") . ":" . line(".")
" if !has_key(g:bpmap, pos)
" let g:bpsignplace += 1
" let g:bpmap[pos] = g:bpsignplace
" exe ":sign place " . g:bpsignplace . " line=" . line(".") . " name=br file=" .expand("%")
" call system("screen -X eval focus 'stuff \"b " . pos . "\"\\015' focus")
" else
" exe ":sign unplace " . g:bpmap[pos]
" unlet g:bpmap[pos]
" call system("screen -X eval focus 'stuff \"clear " . pos . "\"\\015' focus")
" endif
" endf
" nnoremap <F9> :call Breakpoint()<CR>
"
" command! Clear call system("screen -X eval focus 'stuff \"clear " . expand("%") . ":" . line(".") . "\"\\015' focus")
" command! Step call system("screen -X eval focus 'stuff s\\015' focus")
" command! Continue call system("screen -X eval focus 'stuff c\\015' focus")
" command! NextStep call system("screen -X eval focus 'stuff c\\015' focus") | +
" command! Advance call system("screen -X eval focus 'stuff \"advance " . expand("%") . ":" . line(".") . "\"\\015' focus")
" command! -nargs=+ PrintVariable call system("screen -X eval focus 'stuff \"p " . "<args>" . "\"\\015' focus")
" }}}
" mouse and selection should work as in xterm
set visualbell t_vb=
" set terse
" because we prefer terse error messages
"set grepprg=grep\ -Prn\ --exclude-from=$HOME/.grepignore\ '$*'\ *\ /dev/null
" GNU grep 2.5 (requires pcre for -P), use with :grep, :cn, :cp, :cl
" set grepprg=ack\ --nocolor\ --nogroup\ '$*'\ *\ /dev/null
" Trim Blank Lines {{{
fun! TrimBlankLines()
while ( line('.') ) > 1 && getline( line('.') - 1 ) =~ '^\s*$'
cal cursor( line('.')-1, col('.'))
endwhile
cal cursor( line('.')+1 , col('.'))
while getline('.') =~ '^\s*$'
normal dd
endwhile
endf
nnoremap <silent> <leader>t :cal TrimBlankLines()<CR>
inoremap <silent> <C-d> <ESC>:cal TrimBlankLines()<CR>
" }}}
" buffer helper
" XXX: find a better mapping for this , because i am using C-c to do <esc>
"nnoremap <silent> <C-c>j :bn<CR>
"nnoremap <silent> <C-c>k :bp<CR>
"
" cpan.vim hook
let use_pcre_grep = 1
" init perl pm file {{{
fun! s:get_packagename()
return substitute(matchstr(expand('%:r'),'\(lib/\)\@<=.*'),'/','::','g')
endf
fun! s:apply_lines(lines,from,to)
let lines = map(copy(a:lines) , "substitute(v:val,'".a:from."','".a:to."','g')" )
return lines
endf
fun! s:append_pod()
let pkg = s:get_packagename()
let lines = readfile( expand('~/.vim/skeleton/perl.pod') )
let lines = s:apply_lines(lines,'{PackageName}',pkg)
cal append( '$' , lines )
endf
fun! s:init_perl_pkg()
let dir = expand('%:h')
let pkg = s:get_packagename()
silent exec '!mkdir -p ' . dir
call append(0, ["package " . pkg . ';' , 'use warnings;' , 'use strict;' , '' , '1;' ])
endf
autocmd BufNewFile *lib/*.pm :cal s:init_perl_pkg()
autocmd Filetype perl command! AddPod :cal s:append_pod()
"}}}
" Mac clipboard copy from terminal {{{
" nmap <C-y> "+y
" omap <C-y> "+y
" vmap <C-y> "+y
" }}}
" MARKDOWN TEXT FILETYPE "{{{
autocmd BufRead *.mkd :setf mkd
autocmd BufRead *.markdown :setf mkd
"}}}
" TAB HELPER MAPPING {{{
nnoremap <silent> ty :tab split<CR>
nnoremap <silent> td :exec 'tabedit '.expand('%')<CR>
nnoremap <silent> tq :tabclose<CR>
nnoremap <silent> tn :tabnew<CR>
nnoremap <silent> th :tab help<CR>
nnoremap <silent> tmh :exec ':tabmove ' . ( tabpagenr()-2 )<CR>
nnoremap <silent> tml :exec ':tabmove ' . tabpagenr()<CR>
nnoremap <silent> t] gt
nnoremap <silent> t[ gT
" }}}
fun! FTabMoveToLast()
let lasttabnv = tabpagenr()
silent exec ':tabmove ' . lasttabnv
endf
com! TabMoveToLast :call FTabMoveToLast()<CR>
nnoremap <silent> t$ :FTabMoveToLast<CR>
nnoremap <Space> 1<C-E><C-E><C-E><C-E>
nnoremap <leader>ww :w<CR>
nnoremap <leader>wa :wa<CR>
" select function name
" omap F :<C-U>normal! 0f(hviw<CR>
" select perl function name
nnoremap <silent> vF ?sub<CR>WviW
nmap <silent> yF vFy
"
" pod mapping
nnoremap <silent> va= ?^=\w\+<CR>V/^=\w\+<CR>
nnoremap <silent> vi= ?^=\w\+<CR>jV/^=\w\+<CR>k
nmap <silent> ca= va=c
nmap <silent> ci= vi=c
" select/change pod header
" nnoremap <silent> vh ?^=\w\+<CR>Wvg_
" nmap <silent> ch vhc
" Itemfy {{{
fun! Itemfy()
let attr = [ '# vim' , "fdm=expr" , "fdl=1" ]
let expr = "foldexpr=getline(v:lnum)=~'^=='"
\ . "?'>1':getline(v:lnum)[0]=~'[*x(]'"
\ . "?'>2':getline(v:lnum)=~'^--'?'<2':'='"
let expr = substitute( expr , ':' , '\\\:' , 'g')
cal add(attr , expr )
cal append( 0, join( attr ,':') )
w
e! %
endf
com! Itemfy :call Itemfy()
" }}}
" Current Dir vimrc {{{
fun! s:CurDirVIMRC()
if getcwd() == expand("~")
return
endif
for f in [ '.vimrc' , '_vimrc' ]
if filereadable(f)
redraw
exec 'silent so '.f
echo "Found .vimrc in current directory. Loaded"
return
endif
endfor
endf
" com! LoadCurDirVimRC :cal s:CurDirVIMRC()
augroup CurDirVimRC
au!
" autocmd VimEnter * :LoadCurDirVimRC
augroup END
" }}}
" ==================================================
" fucking small <ESC> ( from kana )
map <C-@> <ESC>
" nmap : q:i
nmap ; :
vmap ; :
"nnoremap : ;
"
" cpan.vim mappings {{{
nnoremap <silent> <C-c><C-m> :OpenCPANWindowS<CR>
nnoremap <silent> <C-c><C-v> :OpenCPANWindowSV<CR>
" }}}
"
" Bar Helper "{{{
fun! FillBar(s,e,f)
let cmstr = '"'
let list = [ [a:s,''] ]
if a:s != a:e
cal add(list,[a:e,''])
endif
for [l,fmark] in list
let line = getline( l )
let line = substitute(line,'\s*$','','')
if strlen(line) == 0
let line = cmstr
endif
" padding
let line = line . ' '
let len = 60
for i in range( strlen(line) , len )
let line = line . '='
endfor
if a:f
let line = line . ' ' . fmark
endif
cal setline( l , line )
endfor
endf
com! -range FillBar :cal FillBar(<line1>,<line2>,0)
com! -range FillBarFold :cal FillBar(<line1>,<line2>,1)
com! -range CssToSass :<line1>,<line2>!sass-convert --from css --to sass
com! -range CssToScss :<line1>,<line2>!sass-convert --from css --to scss
"}}}
" Grep CSS"{{{
fun! GrepCSSClass()
let pattern = input('pattern:')
if strlen(pattern) == 0
return
endif
vnew
setl noswapfile buftype=nofile bufhidden=hide
setl nobuflisted nowrap cursorline nonumber fdc=0
exec 'file grep-css-' . pattern
let out = system( printf("ack -A6 --group '^\S.*%s' share/web/static/css/" , pattern ) )
silent put=out
syn match File "^share/.*$"
syn match LineNr "^\d\+:"
syn match Comment +//.*$+
hi link File Function
"setfiletype javascript
cal cursor(1,1)
autocmd BufWinLeave <buffer> :bw
endf
"}}}
" JIFTY GREP JS {{{
fun! GrepJS()
let pattern = input('pattern:')
if strlen(pattern) == 0
return
endif
vnew
setl noswapfile buftype=nofile bufhidden=hide
setl nobuflisted nowrap cursorline nonumber fdc=0
exec 'file grep-js-' . pattern
let out = system( printf("ack --group '%s' share/web/static/js/" , pattern ) )
silent put=out
syn match File "^share/.*$"
syn match LineNr "^\d\+:"
syn match Comment +//.*$+
hi link File Function
"setfiletype javascript
cal cursor(1,1)
autocmd BufWinLeave <buffer> :bw
endf
com! GrepJS :cal GrepJS()
" }}}
com! EnableStringComplete :set omnifunc=StringComplete#GetList
" autocmd FileType html setl omnifunc=htmlcomplete#CompleteTags
" autocmd FileType css setl omnifunc=csscomplete#CompleteCSS
" autocmd FileType xml setl omnifunc=xmlcomplete#CompleteTags
" autocmd FileType php setl omnifunc=phpcomplete#CompletePHP
" autocmd FileType c setl omnifunc=ccomplete#Complete
" com! AutoResource autocmd BufWritePost *.vim,.vimrc :so %
" console menu
:source $VIMRUNTIME/menu.vim
:set cpo-=<
:set wcm=<C-Z>
:map <F4> :emenu <C-Z>
" Gist configuration
if has('mac')
let g:gist_clip_command = 'pbcopy'
let g:gist_open_browser_after_post = 1
let g:gist_browser_command = 'open -a "Google Chrome" %URL%'
" let g:gist_browser_command = 'open -a Chromium %URL%'
endif
" search helper {{{
nmap <C-w>/ <C-w>v<C-w>l:redraw<CR>/
nmap <C-w>* <C-w>v<C-w>l:redraw<CR>*
nmap <C-w># <C-w>v<C-w>l:redraw<CR>#
" }}}
" statusline ================================================
set laststatus=2 " All windows have statusline
if winwidth(0) >= 120
" set statusline=%<[%n]%m%r%h%w%{'['.(&fenc!=''?&fenc:&enc).':'.&ff.']'}%y\ %(%{GitBranch()}\ %)\ %F%=[%{GetB()}]\ %l,%c%V%8P
else
" set statusline=%<[%n]%m%r%h%w%{'['.(&fenc!=''?&fenc:&enc).':'.&ff.']'}%y\ %(%{GitBranch()}\ %)\ %F%=[%{GetB()}]\ %l,%c%V%8P
endif
let status_str =
\ ' %=opt:%{g:optionmode?''o'':''x''}'
"exec 'set statusline=%mb%n:%f%R%Y\ %l/%L,%c:%v' . escape(status_str,' \')
" ignore hidden and unloaded buffers
"set sessionoptions-=buffers
set sessionoptions=tabpages,resize
set isfname-==
au! BufReadPost,BufNewFile *.psgi :setf perl
aug CreateDirectory
au!
au! BufReadPost,BufNewFile * :cal s:CreateDirectory()
fun! s:CreateDirectory()
if &bufhidden
return
endif
if &buftype == "quickfix"
return
endif
let dir = expand( '%:h' )
if ! isdirectory(dir)
echo "Creating directory: " . dir
cal mkdir(dir,'p')
redraw
echo "Directory created: " . dir
redraw
endif
endf
augroup END
fun! s:delete_this_file()
silent exec '!rm ' . expand('%')
silent bw!
endf
com! DeleteThis :cal s:delete_this_file()
cabbr delthis DeleteThis
" virtual tabstops using spaces
" set shiftwidth=4
" set softtabstop=4
" expandtab
" allow toggling between local and default mode
fun! TabToggle()
if &expandtab
set shiftwidth=8
set softtabstop=0
retab!
else
set shiftwidth=4
set softtabstop=4
retab!
endif
endf
set ssop-=folds
com! Big wincmd _ | wincmd |
set cmdwinheight=5
set cmdheight=1
" fuzzyfinder configuration"{{{
nmap <silent> <leader>fb :FufBuffer<CR>
nmap <silent> <leader>ff :FufFile<CR>
"}}}
" ruby rc "{{{
fun! s:ruby_rc()
nmap <C-c><C-c> :w<CR>:!clear && ruby %<CR>
" rubycomplete.vim
let g:rubycomplete_buffer_loading = 1
let g:rubycomplete_classes_in_global = 1
let g:rubycomplete_rails = 0 " i dont need rails
endf
autocmd! filetype ruby :cal s:ruby_rc()
"}}}
" filetype completion hacks {{{
fun! FiletypeCompletion(lead,cmd,pos)
let list = glob(expand('$VIMRUNTIME/syntax'). '/*.vim')
let items = split(list,"\n")
cal map(items,'matchstr(v:val,''\w\+\(.vim$\)\@='')')
cal filter(items,"v:val =~ '^" . a:lead . "'")
return items
endf
com! -complete=customlist,FiletypeCompletion -nargs=1 SetFiletype :setf <args>
cabbr sft SetFiletype
cabbr setf SetFiletype
" }}}
" XXX: plug completion {{{
fun! PlugCompletion(findstart,base)
for func in b:plug_completion
endfor
endf
fun! SetupPlugCompletion(func)
if ! exists('b:plug_completion')
let b:plug_completion = [ &omnifunc ]
set omnifunc=PlugCompletion
endif
cal add(b:plug_completion,a:func)
endf
" }}}
" scopy {{{
fun! s:scopy(host)
echo a:host
let target = '/tmp/' . expand('%:t')
cal system( printf("scp %s %s:%s" , expand('%') , a:host , target ) )
echo a:host . ':' . target
cal system('echo '.a:host.':'.target.' | pbcopy ')
endf
com! -nargs=1 SCopy :cal s:scopy(<q-args>)
com! CopyRelativeFilePath :let @+ = expand('%')
com! CopyFullFilePath :let @+ = expand("%:p")
com! CopyFileName :let @+ = expand("%:t")
" }}}
" vimshell Config {{{
let g:VimShell_EnableInteractive = 1
let g:VimShell_EnableSmartCase = 1
let g:VimShell_EnableAutoLs = 1
" }}}
" open url lines {{{
fun! s:OpenURLLine(f,e)
if ! exists('g:browser_cmd')
if has('mac')
let g:browser_cmd = 'open -a Chromium %s'
else
let g:browser_cmd = 'firefox %s'
endif
endif
let l:cnt = 0
if a:f == a:e
cal system( printf(g:browser_cmd, url ) )
let l:cnt += 1
else
for i in range(a:f,a:e)
let url = getline(i)
if url !~ '^http'
next
endif
redraw
echo "Opening '" . url . "'.."
sleep 300m
cal system( printf(g:browser_cmd, url ) )
let l:cnt += 1
endfor
endif
redraw
echo "Done. " . l:cnt . " Items opened."
endf
com! -range OpenURLLine :cal s:OpenURLLine( <line1> , <line2> )
" }}}
" French Query XXX {{{
fun! FrVerb(word)
:cal system(printf('open http://french.about.com/od/verb_conjugations/%s/%s.htm',a:word[0],a:word))
endf
fun! EnFr(word)
:cal system(printf('open http://www.wordreference.com/enfr/%s',a:word ) )
:cal system(printf('open http://www.babelnation.com/french/dictionary/index.html?qe=%s&qv=%s&q=%s',a:word,a:word,a:word))
:cal system(printf('open http://www.french-linguistics.co.uk/dictionary/englishfrench/?word=%s',a:word))
endf
com! -nargs=1 EnFr :cal EnFr(<q-args>)
com! -nargs=1 FrVerb :cal FrVerb(<q-args>)
" }}}
"nnoremap <CR> 5<C-e>
"nnoremap <S-space> 5<C-e>
let g:bufExplorerFindActive = 0
" pair closing {{{
" inoremap ( ()<ESC>i
" inoremap <expr> ) ClosePair(')')
"
" inoremap { {}<ESC>i
" inoremap <expr> } ClosePair('}')
"
" inoremap [ []<ESC>i
" inoremap <expr> ] ClosePair(']')
"inoremap < <><ESC>i
"inoremap <expr> > ClosePair('>')
" pair close checker.
" from othree vimrc ( http://github.com/othree/rc/blob/master/osx/.vimrc )
fun! ClosePair(char)
if getline('.')[col('.') - 1] == a:char
return "\<Right>"
else
return a:char
endif
endf
" }}}
let g:NERDTreeInitWhenNoMirrorFound = 1
nmap <leader>ak :AckFromSearch<CR>
" bash-like ctrl-k
inoremap <C-k> <C-o>c$
fun! s:edit_wip()
tabedit ~/aiink/wip/current
lcd ~/aiink/wip
endf
com! EditWIP :cal s:edit_wip()
cabbr ewip EditWIP
fun! s:edit_dotfile(file)
exec 'tabedit ~/mygit/private-dotfile/' . a:file
lcd ~/mygit/private-dotfile/
endf
com! EditVimrc :cal s:edit_dotfile('vimrc')
com! EditGVimrc :cal s:edit_dotfile('gvimrc')
"cabbr config EditVimrc
"cabbr gconfig EditGVimrc
" Enable mouse support.
" set mouse=a
" For screen.
if &term =~ "^screen"
augroup MyAutoCmd
autocmd VimLeave * :set mouse=
augroup END
" screenでマウスを使用するとフリーズするのでその対策
set ttymouse=xterm2
endif
" i like to use different register for cut,copy,paste
"nnoremap yy "0y
"vnoremap y "0y
"nnoremap p "0p
"vnoremap x "0d
"cabbr ejs tabedit share/web/static/js/
" Todo should be always highlighted.
hi Todo guibg=yellow guifg=black ctermbg=yellow ctermfg=black
" Enable Perl Folding"{{{
let perl_fold = 1
let perl_fold_blocks = 1
let perl_include_pod = 1
"}}}
" Extra Plugin Loader {{{
" mv your seldom used plugin files to ~/.vim/extra_plugin/ directory
" and you can load plugins in oneline
" e.g.
" LoadExtraPlugin vimshell.vim gist.vim
"
" completion is supported.
let g:extra_plugin_dir = '~/.vim/extra_plugin/'
fun! ExtraPluginNameCompletion(lead,cmd,cur)
let args = split(a:cmd)
cal remove(args,0)
if strlen(a:lead) > 0
cal remove(args,-1)
endif
let path = split(glob(g:extra_plugin_dir.'*'))
let names = map(path, 'matchstr(v:val,''\(/\)\@<=[a-zA-Z0-9-_+.]*$'')' )
cal filter(names," v:val =~ '^".a:lead."'")
let comps = { }
for n in extend(names,args)
let comps[ n ] = 1
endfor
for a in args
unlet comps[ a ]
endfor
return keys(comps)
endf
fun! s:LoadExtraPlugin(args)
for plugin in split(a:args)
echohl MoreMsg | echo "Loading " . plugin . " plugin..." | echohl None
exec ':source ' . g:extra_plugin_dir . plugin
endfor
echohl MoreMsg | echo "Done" | echohl None
endf
com! -nargs=+ -complete=customlist,ExtraPluginNameCompletion -nargs=1 LoadExtraPlugin :cal s:LoadExtraPlugin(<q-args>)
" }}}
" nmap <leader>cc :set cursorline!<CR>
" Extend Perl Moose Syntax
" let disable_moose_extends = 1
" Insert Images from a path {{{
fun! s:InsertImage(path)
let files = split(glob( a:path . '/*'))
for f in files
let img = printf('<img src="%s"/>',f)
put=img
endfor
endf
com! -nargs=1 -complete=dir InsertImage :cal s:InsertImage(<q-args>)
" }}}
" Copy to then end of line {{{
nnoremap Y y$
" }}}
" New from file {{{
fun! s:NewFromFile(file)
let file = a:file
if strlen( a:file ) == 0
let file = expand('%')
endif
let newfile = input('New Filename:',file,'file')
cal system(printf('cp %s %s',file,newfile))
exec 'tabedit ' . newfile
endf
com! -nargs=? -complete=file NewFromFile :cal s:NewFromFile(<q-args>)
" }}}
" Window Resize Mode for Terminal {{{
fun! s:ResizeMode()
let degree = 5
if ! exists('g:resize_mode')
let g:resize_mode = 1
exec 'nmap <buffer> > :vertical resize +'.degree.'<CR>'
exec 'nmap <buffer> < :vertical resize -'.degree.'<CR>'
exec 'nmap <buffer> <Left> :vertical resize +'.degree.'<CR>'
exec 'nmap <buffer> <Right> :vertical resize -'.degree.'<CR>'
exec 'nmap <buffer> + :resize +'.degree.'<CR>'
exec 'nmap <buffer> - :resize -'.degree.'<CR>'
exec 'nmap <buffer> <Up> :resize +'.degree.'<CR>'
exec 'nmap <buffer> <Down> :resize -'.degree.'<CR>'
echo "ResizeMode On"
else
nunmap <buffer> >
nunmap <buffer> <
nunmap <buffer> <Left>
nunmap <buffer> <Right>
nunmap <buffer> <Up>
nunmap <buffer> <Down>
nunmap <buffer> +
nunmap <buffer> -
unlet g:resize_mode
echo "ResizeMode Off"
endif
endf
nnoremap <C-w><leader> :ResizeMode<CR>
com! ResizeMode :cal s:ResizeMode()
" }}}
autocmd BufRead *.txt :setf txt
" Vim Function Implementor {{{
" cal s:Test( test )
" - c9s
fun! g:ImVimFunction()
let line = getline('.')
normal B
let ocol = col('.')-1
let col = col('.')
while col > 0 && line[ col - 1] =~ '[a-zA-Z0-9:_.,() ''"]'
let col += 1
endwhile
let funname = strpart(line,ocol,col-ocol)
normal {
cal append('.', [ "fun! " . funname , "", "endf", "" ] )
cal cursor( line('.') + 2 , col('.') )
startinsert
cal feedkeys("\t")
endf
autocmd filetype vim :nmap <silent><buffer> <C-x><C-i> :cal g:ImVimFunction()<CR>
" }}}
" change local buffer current directory to the current file parent directory. {{{
" and change to parent dir if a git directory is found in parent directory.
"
" - c9s
fun! s:LocalChangeDir(local)
let path = expand('%:p:h')
let parts = split(path,'/')
let paths = []
for i in range(1,len(parts))
cal add(paths, '/'.join(parts,'/'))
cal remove(parts,-1)
endfor
for p in paths
if isdirectory(p . '/.git')
redraw
if a:local
echo 'Found .git dir. Changing local directory to: ' . p
exec 'lcd ' . p
else
echo 'Found .git dir. Changing directory to: ' . p
exec 'cd ' . p
endif
return
endif
endfor
redraw
if a:local
echo 'Changing local directory to: ' . path
exec 'lcd ' . path
else
echo 'Changing directory to: ' . path
exec 'cd ' . path
endif
endf
com! LC :cal s:LocalChangeDir(0)
com! LLC :cal s:LocalChangeDir(1)
" }}}
func! g:MarkdownPostWrite()
let filename = expand('%')
let message = "Update " . filename
if isdirectory('.git')
if strlen(system('git diff --ignore-all-space ' . filename)) > 0
" echohl ModeMsg | echon 'Committing: ' . message | echohl None
echo 'Committing: ' . message
let cmd = 'git commit ' . filename . ' -m "' . message . '"'
echo system(cmd)
else
" echohl ModeMsg | echon 'Nothing changed' | echohl None
echo 'Nothing changed.'
endif
endif
endfunc
" autocmd BufWritePost *.md :call g:MarkdownPostWrite()
" force reload flag for some plugin
let force_reload = 1
let g:netrw_liststyle = 3 " 0=thin 1=long 2=wide 3=tree
" new temp file command.
com! NewTemp :exec 'tabe ' . tempname()
" vim messages command
nmap ,m :messages<CR>
nmap <silent> == {=}''
com! WinMax :winsize 159 46
" OpenFilesUnder {{{
fun! OpenFilesUnder( dir )
let list = split(glob(a:dir . "*"),"\n")
for f in list
exec 'tabe ' . f
endfor
endf
com! -narg=1 -complete=dir OpenFilesUnder :cal OpenFilesUnder( <f-args> )
" }}}
" Auto bump vimrc version number {{{
" 用來自動 bump version number 以及 date 的 script:
"
" http://gist.github.com/339094
"
" 用法:
"
" 加到 .vimrc ,在 vimrc 開頭的前十行加上:
"
" " Date:
" " " Version: 0.1
" "
" " 存檔之後重開,每次寫入檔案就會自動 bump version.
"
fun! BumpVimrcVersion()
let lines = getline(1,10)
let i = 0
for line in lines
let i += 1
if line =~ '^"\s*Version:'
let version_str = matchstr(line,'\(Version:\s*\)\@<=[0-9.]\+')
let vimrc_version = str2float(version_str) + 0.01
cal setline( i, "\" Version: " . string(vimrc_version) )
elseif line =~ '^"\s*Date:'
cal setline( i, "\" Date: " . strftime("%c") )
endif
endfor
endf
aug AutoVimrcVersion
au!
" au BufWritePre .vimrc :cal BumpVimrcVersion()
aug END
com! BumpVersion :cal BumpVimrcVersion()
" }}}
com! -complete=custom,ListUsers -nargs=1 Finger !finger <args>
fun! ListUsers(A,L,P)
return system("cut -d: -f1 /etc/passwd")
endfun
" xptemplate:
" let g:xptemplate_key = '<C-t>'
" au BufNewFile Makefile.PL exec feedkeys("imi")
com! -range JSON2HASH :'<,'> !~/bin/json2hash.pl
" disable sql default maps
let g:omni_sql_no_default_maps = 1
fun! s:init_yaml()
setlocal sw=2 et
setlocal list
setlocal lcs=tab:>-,trail:-,nbsp:_
endf
au Filetype yaml :cal s:init_yaml()
fun! g:Go_package_from_file()
let name = expand('%:p:h:t')
return name
endfunction
" php functions
fun! g:Php_class_from_path()
let file = expand('%:t:r') " last path component and remove extension..
return toupper( file[0] ) . file[1:]
endfunction
fun! g:Php_ns_from_path()
let path = expand('%:h')
" let path = substitute(path,'^\(src\|lib\|tests\|bundles\|applications\)/','','')
let path = substitute(path,'^[a-z]\+/','','')
let parts = split( path , '/' )
let ns = [ ]
for p in parts
let p = toupper(p[0]) . p[1:]
cal add( ns , p )
endfor
return join(ns,'\\')
endfunction
let g:ctrlp_map = '<c-m>'
" must be the last line
set expandtab
set list
set listchars=tab:>-
com! Sketch :call ToggleSketch()
" configure type go ctags
let g:tagbar_type_go = {
\ 'ctagstype' : 'go',
\ 'kinds' : [
\ 'p:package',
\ 'i:imports:1',
\ 'c:constants',
\ 'v:variables',
\ 't:types',
\ 'n:interfaces',
\ 'w:fields',
\ 'e:embedded',
\ 'm:methods',
\ 'r:constructor',
\ 'f:functions'
\ ],
\ 'sro' : '.',
\ 'kind2scope' : {
\ 't' : 'ctype',
\ 'n' : 'ntype'
\ },
\ 'scope2kind' : {
\ 'ctype' : 't',
\ 'ntype' : 'n'
\ },
\ 'ctagsbin' : 'gotags',
\ 'ctagsargs' : '-sort -silent'
\ }
nmap <leader>l :TagbarToggle<CR>
let g:acp_enableAtStartup = 0
let g:neocomplete#enable_at_startup = 1
let g:neocomplete#enable_smart_case = 1
let g:neocomplete#sources#syntax#min_keyword_length = 3
" autocmd FileType php setlocal omnifunc=phpcomplete#CompleteTags
let g:rtfp_font = 'Monaco'
let g:rtfp_theme = 'monokai'
" this will auto-refresh the file after modification from else where.
set autoread
" MacVim Configurations {{{
if has('gui_macvim')
set showtabline=2
set imdisable
set transparency=0 " 透明度を指定
set guioptions-=m
set guioptions-=M
set antialias
" set guifont=Consolas:h11
set guifont=Monaco:h14
" set guifont=Consolas:h12
" set guifont=Monaco:h14
" set guifont=Menlo:h12
" set guifont=Courier\ New:h13
elseif has('gui_gtk2')
set guifont=Bitstream\ Vera\ Sans\ Mono\ 10
"set gfn=ProggyCleanTT\ CE\ 12
"set gfn=ProggyCleanTT_CE:h16
"set gfn=ProggySquareTT\ 12
"set gfn=Crisp\ 12
elseif has('gui_win32')
"set gfn=Consolas\ 10
set guifont=Courier\ New:h12
else
colors default
endif
"}}}
command Tidy :!tidy -mi -html -wrap %
" go related configurations
let g:go_fmt_fail_silently = 1
let g:go_fmt_autosave = 1
let g:go_highlight_functions = 1
let g:go_highlight_methods = 1
let g:go_highlight_structs = 1
let g:go_highlight_operators = 1
let g:go_highlight_build_constraints = 1
let g:tagbar_type_go = {
\ 'ctagstype' : 'go',
\ 'kinds' : [
\ 'p:package',
\ 'i:imports:1',
\ 'c:constants',
\ 'v:variables',
\ 't:types',
\ 'n:interfaces',
\ 'w:fields',
\ 'e:embedded',
\ 'm:methods',
\ 'r:constructor',
\ 'f:functions'
\ ],
\ 'sro' : '.',
\ 'kind2scope' : {
\ 't' : 'ctype',
\ 'n' : 'ntype'
\ },
\ 'scope2kind' : {
\ 'ctype' : 't',
\ 'ntype' : 'n'
\ },
\ 'ctagsbin' : 'gotags',
\ 'ctagsargs' : '-sort -silent'
\ }
" optimize html rendering
let html_no_rendering=1
vnoremap ta :GTabularize/@\w\+\s\+\zs\S\+\|\%(@\w\+.*\)\@<=\u.*/<CR>
set secure
" ir_black color scheme
" More at: http://blog.infinitered.com/entries/show/8
" ********************************************************************************
" Standard colors used in all ir_black themes:
" Note, x:x:x are RGB values
"
" normal: #f6f3e8
"
" string: #A8FF60 168:255:96
" string inner (punc, code, etc): #00A0A0 0:160:160
" number: #FF73FD 255:115:253
" comments: #7C7C7C 124:124:124
" keywords: #96CBFE 150:203:254
" operators: white
" class: #FFFFB6 255:255:182
" method declaration name: #FFD2A7 255:210:167
" regular expression: #E9C062 233:192:98
" regexp alternate: #FF8000 255:128:0
" regexp alternate 2: #B18A3D 177:138:61
" variable: #C6C5FE 198:197:254
"
" Misc colors:
" red color (used for whatever): #FF6C60 255:108:96
" light red: #FFB6B0 255:182:176
"
" brown: #E18964 good for special
"
" lightpurpleish: #FFCCFF
"
" Interface colors:
" background color: black
" cursor (where underscore is used): #FFA560 255:165:96
" cursor (where block is used): white
" visual selection: #1D1E2C
" current line: #151515 21:21:21
" search selection: #07281C 7:40:28
" line number: #3D3D3D 61:61:61
" ********************************************************************************
" The following are the preferred 16 colors for your terminal
" Colors Bright Colors
" Black #4E4E4E #7C7C7C
" Red #FF6C60 #FFB6B0
" Green #A8FF60 #CEFFAB
" Yellow #FFFFB6 #FFFFCB
" Blue #96CBFE #FFFFCB
" Magenta #FF73FD #FF9CFE
" Cyan #C6C5FE #DFDFFE
" White #EEEEEE #FFFFFF
" ********************************************************************************
set background=dark
hi clear
if exists("syntax_on")
syntax reset
endif
let colors_name = "ir_black"
"hi Example guifg=NONE guibg=NONE gui=NONE ctermfg=NONE ctermbg=NONE cterm=NONE
" General colors
hi Normal guifg=#f6f3e8 guibg=black gui=NONE ctermfg=NONE ctermbg=NONE cterm=NONE
hi NonText guifg=#070707 guibg=black gui=NONE ctermfg=black ctermbg=NONE cterm=NONE
hi Cursor guifg=black guibg=white gui=NONE ctermfg=black ctermbg=white cterm=reverse
hi LineNr guifg=#3D3D3D guibg=black gui=NONE ctermfg=darkgray ctermbg=NONE cterm=NONE
hi VertSplit guifg=#202020 guibg=#202020 gui=NONE ctermfg=darkgray ctermbg=darkgray cterm=NONE
hi StatusLine guifg=#CCCCCC guibg=#202020 gui=italic ctermfg=white ctermbg=darkgray cterm=NONE
hi StatusLineNC guifg=black guibg=#202020 gui=NONE ctermfg=blue ctermbg=darkgray cterm=NONE
hi Folded guifg=#a0a8b0 guibg=#384048 gui=NONE ctermfg=NONE ctermbg=NONE cterm=NONE
hi Title guifg=#f6f3e8 guibg=NONE gui=bold ctermfg=NONE ctermbg=NONE cterm=NONE
hi Visual guifg=NONE guibg=#262D51 gui=NONE ctermfg=NONE ctermbg=darkgray cterm=NONE
hi SpecialKey guifg=#808080 guibg=#343434 gui=NONE ctermfg=NONE ctermbg=NONE cterm=NONE
hi WildMenu guifg=green guibg=yellow gui=NONE ctermfg=black ctermbg=yellow cterm=NONE
hi PmenuSbar guifg=black guibg=white gui=NONE ctermfg=black ctermbg=white cterm=NONE
"hi Ignore guifg=gray guibg=black gui=NONE ctermfg=NONE ctermbg=NONE cterm=NONE
hi Error guifg=NONE guibg=NONE gui=undercurl ctermfg=white ctermbg=red cterm=NONE guisp=#FF6C60 " undercurl color
hi ErrorMsg guifg=white guibg=#FF6C60 gui=BOLD ctermfg=white ctermbg=red cterm=NONE
hi WarningMsg guifg=white guibg=#FF6C60 gui=BOLD ctermfg=white ctermbg=red cterm=NONE
" Message displayed in lower left, such as --INSERT--
hi ModeMsg guifg=black guibg=#C6C5FE gui=BOLD ctermfg=black ctermbg=cyan cterm=BOLD
if version >= 700 " Vim 7.x specific colors
hi CursorLine guifg=NONE guibg=#121212 gui=NONE ctermfg=NONE ctermbg=NONE cterm=BOLD
hi CursorColumn guifg=NONE guibg=#121212 gui=NONE ctermfg=NONE ctermbg=NONE cterm=BOLD
hi MatchParen guifg=#f6f3e8 guibg=#857b6f gui=BOLD ctermfg=white ctermbg=darkgray cterm=NONE
hi Pmenu guifg=#f6f3e8 guibg=#444444 gui=NONE ctermfg=NONE ctermbg=NONE cterm=NONE
hi PmenuSel guifg=#000000 guibg=#cae682 gui=NONE ctermfg=NONE ctermbg=NONE cterm=NONE
hi Search guifg=white guibg=darkred gui=underline ctermfg=NONE ctermbg=NONE cterm=underline
endif
" Syntax highlighting
hi Comment guifg=#7C7C7C guibg=NONE gui=italic ctermfg=darkgray ctermbg=NONE cterm=NONE
hi String guifg=#A8FF60 guibg=NONE gui=NONE ctermfg=green ctermbg=NONE cterm=NONE
hi Number guifg=#FF73FD guibg=NONE gui=NONE ctermfg=magenta ctermbg=NONE cterm=NONE
hi Keyword guifg=#96CBFE guibg=NONE gui=NONE ctermfg=blue ctermbg=NONE cterm=NONE
hi PreProc guifg=#96CBFE guibg=NONE gui=NONE ctermfg=blue ctermbg=NONE cterm=NONE
hi Conditional guifg=#6699CC guibg=NONE gui=NONE ctermfg=blue ctermbg=NONE cterm=NONE " if else end
hi Todo guifg=#000000 guibg=gold gui=NONE ctermfg=red ctermbg=NONE cterm=NONE
hi Constant guifg=#99CC99 guibg=NONE gui=NONE ctermfg=cyan ctermbg=NONE cterm=NONE
hi Identifier guifg=#C6C5FE guibg=NONE gui=NONE ctermfg=cyan ctermbg=NONE cterm=NONE
hi Function guifg=#FFD2A7 guibg=NONE gui=NONE ctermfg=brown ctermbg=NONE cterm=NONE
hi Type guifg=#FFFFB6 guibg=NONE gui=NONE ctermfg=yellow ctermbg=NONE cterm=NONE
hi Statement guifg=#6699CC guibg=NONE gui=NONE ctermfg=lightblue ctermbg=NONE cterm=NONE
hi Special guifg=#E18964 guibg=NONE gui=NONE ctermfg=white ctermbg=NONE cterm=NONE
hi Delimiter guifg=#00A0A0 guibg=NONE gui=NONE ctermfg=cyan ctermbg=NONE cterm=NONE
hi Operator guifg=white guibg=NONE gui=NONE ctermfg=white ctermbg=NONE cterm=NONE
hi link Character Constant
hi link Boolean Constant
hi link Float Number
hi link Repeat Statement
hi link Label Statement
hi link Exception Statement
hi link Include PreProc
hi link Define PreProc
hi link Macro PreProc
hi link PreCondit PreProc
hi link StorageClass Type
hi link Structure Type
hi link Typedef Type
hi link Tag Special
hi link SpecialChar Special
hi link SpecialComment Special
hi link Debug Special
" Special for Ruby
hi rubyRegexp guifg=#B18A3D guibg=NONE gui=NONE ctermfg=brown ctermbg=NONE cterm=NONE
hi rubyRegexpDelimiter guifg=#FF8000 guibg=NONE gui=NONE ctermfg=brown ctermbg=NONE cterm=NONE
hi rubyEscape guifg=white guibg=NONE gui=NONE ctermfg=cyan ctermbg=NONE cterm=NONE
hi rubyInterpolationDelimiter guifg=#00A0A0 guibg=NONE gui=NONE ctermfg=blue ctermbg=NONE cterm=NONE
hi rubyControl guifg=#6699CC guibg=NONE gui=NONE ctermfg=blue ctermbg=NONE cterm=NONE "and break, etc
"hi rubyGlobalVariable guifg=#FFCCFF guibg=NONE gui=NONE ctermfg=lightblue ctermbg=NONE cterm=NONE "yield
hi rubyStringDelimiter guifg=#336633 guibg=NONE gui=NONE ctermfg=lightgreen ctermbg=NONE cterm=NONE
"rubyInclude
"rubySharpBang
"rubyAccess
"rubyPredefinedVariable
"rubyBoolean
"rubyClassVariable
"rubyBeginEnd
"rubyRepeatModifier
"hi link rubyArrayDelimiter Special " [ , , ]
"rubyCurlyBlock { , , }
hi link rubyClass Keyword
hi link rubyModule Keyword
hi link rubyKeyword Keyword
hi link rubyOperator Operator
hi link rubyIdentifier Identifier
hi link rubyInstanceVariable Identifier
hi link rubyGlobalVariable Identifier
hi link rubyClassVariable Identifier
hi link rubyConstant Type
" Special for Java
" hi link javaClassDecl Type
hi link javaScopeDecl Identifier
hi link javaCommentTitle javaDocSeeTag
hi link javaDocTags javaDocSeeTag
hi link javaDocParam javaDocSeeTag
hi link javaDocSeeTagParam javaDocSeeTag
hi javaDocSeeTag guifg=#CCCCCC guibg=NONE gui=NONE ctermfg=darkgray ctermbg=NONE cterm=NONE
hi javaDocSeeTag guifg=#CCCCCC guibg=NONE gui=NONE ctermfg=darkgray ctermbg=NONE cterm=NONE
"hi javaClassDecl guifg=#CCFFCC guibg=NONE gui=NONE ctermfg=white ctermbg=NONE cterm=NONE
" Special for XML
hi link xmlTag Keyword
hi link xmlTagName Conditional
hi link xmlEndTag Identifier
" Special for HTML
hi link htmlTag Keyword
hi link htmlTagName Conditional
hi link htmlEndTag Identifier
" Special for Javascript
hi link javaScriptNumber Number
" Special for Python
"hi link pythonEscape Keyword
" Special for CSharp
hi link csXmlTag Keyword
" Special for PHP
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.