Created
August 30, 2013 09:25
-
-
Save medvid/6388019 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set nocompatible | |
let s:is_windows = has('win16') || has('win32') || has('win64') | |
let s:is_cygwin = has('win32unix') | |
if s:is_windows | |
set rtp^=~/.vim | |
endif | |
let g:mapleader = ',' | |
let g:maplocalleader = 'm' | |
nnoremap ; <Nop> | |
xnoremap ; <Nop> | |
nnoremap m <Nop> | |
xnoremap m <Nop> | |
nnoremap , <Nop> | |
xnoremap , <Nop> | |
if s:is_windows | |
set shellslash | |
endif | |
let $DOTVIM = expand('~/.vim') | |
if !exists($MYGVIMRC) | |
let $MYGVIMRC = expand('~/.gvimrc') | |
endif | |
" Anywhere SID. | |
function! s:SID_PREFIX() | |
return matchstr(expand('<sfile>'), '<SNR>\d\+_\zeSID_PREFIX$') | |
endfunction | |
" Set augroup. | |
augroup MyAutoCmd | |
autocmd! | |
augroup END | |
set runtimepath+=~/.vim/bundle/neobundle.vim | |
call neobundle#rc(expand('~/.vim/bundle/')) | |
" neobundle.vim"{{{ | |
NeoBundleFetch 'Shougo/neobundle.vim' | |
NeoBundle 'tpope/vim-surround', { | |
\ 'autoload' : { | |
\ 'mappings' : [ | |
\ ['n', '<Plug>Dsurround'], ['n', '<Plug>Csurround'], | |
\ ['n', '<Plug>Ysurround'], ['n', '<Plug>YSurround'] | |
\ ]}} | |
NeoBundle 'Shougo/neocomplete.vim' | |
NeoBundle 'Shougo/neosnippet' | |
NeoBundle 'Shougo/neobundle-vim-scripts' | |
NeoBundle 'Shougo/unite.vim' | |
NeoBundle 'Shougo/unite-build' | |
NeoBundle 'Shougo/unite-ssh' | |
NeoBundle 'Shougo/unite-sudo' | |
NeoBundleLazy 'Shougo/vim-vcs', { | |
\ 'depends' : 'thinca/vim-openbuf', | |
\ 'autoload' : {'commands' : 'Vcs'}, | |
\ } | |
NeoBundle 'Shougo/vimfiler' | |
NeoBundle 'Shougo/vimproc' | |
NeoBundle 'Shougo/vinarise' | |
NeoBundle 'Shougo/vesting' | |
NeoBundle 'vim-jp/vital.vim' | |
NeoBundle 'Shougo/junkfile.vim' | |
NeoBundle 'hrsh7th/vim-versions' | |
" NeoBundle 'h1mesuke/unite-outline' | |
NeoBundle 'Shougo/unite-outline' | |
NeoBundleLazy 'hail2u/vim-css3-syntax' | |
NeoBundleLazy 'kana/vim-smartword', { 'autoload' : { | |
\ 'mappings' : [ | |
\ '<Plug>(smartword-w)', '<Plug>(smartword-b)', '<Plug>(smartword-ge)'] | |
\ }} | |
NeoBundleLazy 'kana/vim-smarttill', { 'autoload' : { | |
\ 'mappings' : [ | |
\ '<Plug>(smarttill-t)', '<Plug>(smarttill-T)'] | |
\ }} | |
NeoBundle 'kana/vim-operator-user', { | |
\ 'autoload' : { | |
\ 'functions' : 'operator#user#define', | |
\ }} | |
NeoBundleLazy 'kana/vim-operator-replace', { | |
\ 'depends' : 'vim-operator-user', | |
\ 'autoload' : { | |
\ 'mappings' : [ | |
\ ['nx', '<Plug>(operator-replace)']] | |
\ }} | |
NeoBundleLazy 'kana/vim-textobj-user' | |
" NeoBundleLazy 'kana/vim-wwwsearch' | |
NeoBundleLazy 'mattn/wwwrenderer-vim' | |
NeoBundleLazy 'mattn/webapi-vim' | |
" NeoBundle 'basyura/webapi-vim' | |
NeoBundleLazy 'sjl/gundo.vim', { 'autoload' : { | |
\ 'commands' : 'GundoToggle' | |
\ }} | |
NeoBundleLazy 'thinca/vim-fontzoom', { | |
\ 'gui' : 1, | |
\ 'autoload' : { | |
\ 'mappings' : [ | |
\ ['n', '<Plug>(fontzoom-larger)'], | |
\ ['n', '<Plug>(fontzoom-smaller)']] | |
\ }} | |
NeoBundleLazy 'thinca/vim-qfreplace', { 'autoload' : { | |
\ 'filetypes' : ['unite', 'quickfix'], | |
\ }} | |
NeoBundleLazy 'thinca/vim-quickrun', { 'autoload' : { | |
\ 'mappings' : [ | |
\ ['nxo', '<Plug>(quickrun)']], | |
\ }} | |
NeoBundleLazy 'thinca/vim-scouter', { 'autoload' : { | |
\ 'commands' : 'Scouter' | |
\ }} | |
NeoBundleLazy 'thinca/vim-ref', { 'autoload' : { | |
\ 'commands' : 'Ref' | |
\ }} | |
NeoBundleLazy 'thinca/vim-unite-history', { 'autoload' : { | |
\ 'unite_sources' : ['history/command', 'history/search'] | |
\ }} | |
NeoBundleLazy 'vim-ruby/vim-ruby', { 'autoload' : { | |
\ 'mappings' : '<Plug>(ref-keyword)', | |
\ 'filetypes' : 'ruby' | |
\ }} | |
NeoBundleLazy 'Shougo/unite-help', { 'autoload' : { | |
\ 'unite_sources' : 'help' | |
\ }} | |
NeoBundleLazy 'tsukkee/unite-tag', { 'autoload' : { | |
\ 'unite_sources' : 'tag' | |
\ }} | |
NeoBundleLazy 'tyru/caw.vim', { 'autoload' : { | |
\ 'mappings' : [ | |
\ '<Plug>(caw:prefix)', '<Plug>(caw:i:toggle)'] | |
\ }} | |
NeoBundleLazy 'tyru/open-browser.vim', { 'autoload' : { | |
\ 'mappings' : '<Plug>(open-browser-wwwsearch)', | |
\ }} | |
NeoBundleLazy 'tyru/operator-html-escape.vim' | |
NeoBundleLazy 'tyru/restart.vim', { | |
\ 'gui' : 1, | |
\ 'autoload' : { | |
\ 'commands' : 'Restart' | |
\ }} | |
NeoBundleLazy 'tyru/vim-altercmd' | |
NeoBundleLazy 'ujihisa/neco-ghc', { 'autoload' : { | |
\ 'filetypes' : 'haskell' | |
\ }} | |
NeoBundle 'ujihisa/neco-look' | |
NeoBundleLazy 'ujihisa/unite-colorscheme', { 'autoload' : { | |
\ 'unite_sources' : 'colorscheme', | |
\ }} | |
NeoBundleLazy 'ujihisa/unite-locate', { 'autoload' : { | |
\ 'unite_sources' : 'locate', | |
\ }} | |
" NeoBundleLazy 'vim-scripts/netrw.vim', { 'autoload' : { | |
" \ 'commands' : 'Explore', | |
" \ }} | |
" NeoBundleLazy 'Markdown' | |
NeoBundleLazy 'yuratomo/w3m.vim', { 'autoload' : { | |
\ 'commands' : 'W3m', | |
\ }} | |
NeoBundleLazy 'pasela/unite-webcolorname', { 'autoload' : { | |
\ 'unite_sources' : 'webcolorname', | |
\ }} | |
" NeoBundle 'hrsh7th/vim-unite-vcs' | |
NeoBundleLazy 'osyo-manga/unite-quickfix', { 'autoload' : { | |
\ 'unite_sources' : 'quickfix', | |
\ }} | |
NeoBundleLazy 'osyo-manga/unite-filetype', { 'autoload' : { | |
\ 'unite_sources' : 'filetype', | |
\ }} | |
NeoBundleLazy 'rbtnn/hexript.vim' | |
NeoBundleLazy 'tpope/vim-endwise' | |
NeoBundleLazy 'kana/vim-tabpagecd' | |
NeoBundleLazy 'rhysd/accelerated-jk', { 'autoload' : { | |
\ 'mappings' : ['<Plug>(accelerated_jk_gj)', | |
\ '<Plug>(accelerated_jk_gk)'], | |
\ }} | |
" NeoBundle 'gmarik/vundle' | |
NeoBundleLazy 'vim-jp/autofmt', { 'autoload' : { | |
\ 'mappings' : [['x', 'gq']], | |
\ }} | |
NeoBundleLazy 'deton/jasegment.vim', { 'autoload' : { | |
\ 'mappings' : [['n', '<Plug>JaSegmentMoveNE'], | |
\ ['n', '<Plug>JaSegmentMoveNW'], | |
\ ['n', '<Plug>JaSegmentMoveNB'], | |
\ ['o', '<Plug>JaSegmentMoveOE'], | |
\ ['o', '<Plug>JaSegmentMoveOW'], | |
\ ['o', '<Plug>JaSegmentMoveOB'], | |
\ ['x', '<Plug>JaSegmentMoveVE'], | |
\ ['x', '<Plug>JaSegmentMoveVW'], | |
\ ['x', '<Plug>JaSegmentMoveVB'], | |
\ ], | |
\ }} | |
" From vim.org | |
NeoBundleLazy 'repeat.vim', { 'autoload' : { | |
\ 'mappings' : '.', | |
\ }} | |
NeoBundleLazy 'autodate.vim', { 'autoload' : { | |
\ 'filetypes' : 'vim', | |
\ }} | |
NeoBundleLazy 'matchit.zip', { 'autoload' : { | |
\ 'filetypes' : 'vim', | |
\ }} | |
NeoBundleLazy 'bkad/CamelCaseMotion', { 'autoload' : { | |
\ 'mappings' : ['<Plug>CamelCaseMotion_w', | |
\ '<Plug>CamelCaseMotion_b'], | |
\ }} | |
NeoBundleLazy 'kana/vim-niceblock', { 'autoload' : { | |
\ 'mappings' : ['<Plug>(niceblock-I)', '<Plug>(niceblock-A)'] | |
\ }} | |
NeoBundleLazy 'vim-jp/cpp-vim', { 'autoload' : { | |
\ 'filetypes' : 'cpp', | |
\ }} | |
NeoBundleLazy 'thinca/vim-ft-diff_fold', { 'autoload' : { | |
\ 'filetypes' : 'diff' | |
\ }} | |
NeoBundleLazy 'thinca/vim-ft-markdown_fold', { 'autoload' : { | |
\ 'filetypes' : 'markdown' | |
\ }} | |
NeoBundleLazy 'thinca/vim-ft-help_fold', { | |
\ 'autoload' : { | |
\ 'filetypes' : 'help' | |
\ }} | |
if has('conceal') | |
NeoBundle 'Yggdroot/indentLine' | |
endif | |
NeoBundleLazy 'itchyny/thumbnail.vim', { | |
\ 'autoload' : { | |
\ 'commands' : 'Thumbnail' | |
\ }} | |
NeoBundleLazy 'mopp/unite-battle_editors.git', { | |
\ 'autoload' : { | |
\ 'unite_sources' : 'battle_editors' | |
\ }, | |
\ 'depends' : 'mattn/webapi-vim', | |
\} | |
NeoBundleLazy 'xolox/vim-lua-ftplugin', { | |
\ 'autoload' : { | |
\ 'filetypes' : 'lua', | |
\ }} | |
NeoBundleLazy 'elzr/vim-json', { | |
\ 'autoload' : { | |
\ 'filetypes' : 'json', | |
\ }} | |
NeoBundleLazy 'tyru/open-browser.vim', { | |
\ 'autoload' : { | |
\ 'commands' : ['OpenBrowserSearch', 'OpenBrowser'], | |
\ 'functions' : 'openbrowser#open', | |
\ }} | |
" A secure alternative to modelines | |
NeoBundle 'ciaranm/securemodelines' | |
" Fast and lightweight alternative to powerline | |
NeoBundle 'bling/vim-airline' | |
let g:airline_theme='molokai' | |
" Easy to use, file-type sensible comments | |
NeoBundle 'tomtom/tcomment_vim', { | |
\ 'depends' : 'tomtom/tlib_vim' | |
\ } | |
" Snippets files for various programming languages. | |
NeoBundle 'honza/vim-snippets' | |
NeoBundle 'Shougo/context_filetype.vim' | |
" NeoBundle 'tpope/vim-fugitive' | |
" More useful search commands | |
NeoBundle 'henrik/vim-indexed-search' | |
" Automatically restore one file's cursor position | |
" and folding information after restart vim | |
NeoBundle 'restore_view.vim' | |
let g:skipview_files = ['COMMIT_EDITMSG'] | |
" Syntax highlighting for ARM assembly language | |
NeoBundle 'medvid/vim-armasm' | |
let asmsyntax='armasm' | |
let filetype_inc='armasm' | |
" Define a different filetype syntax on regions of a buffer | |
NeoBundle 'SyntaxRange' | |
NeoBundleLazy 'mattn/gist-vim', { | |
\ 'autoload' : { | |
\ 'commands' : 'Gist' | |
\ }, | |
\ 'depends' : 'mattn/webapi-vim', | |
\} | |
" NeoBundle configurations. | |
call neobundle#config('neosnippet', { | |
\ 'lazy' : 1, | |
\ 'autoload' : { | |
\ 'insert' : 1, | |
\ 'filetypes' : 'snippet', | |
\ 'unite_sources' : ['snippet', 'neosnippet/user', 'neosnippet/runtime'], | |
\ }}) | |
call neobundle#config('unite.vim',{ | |
\ 'lazy' : 1, | |
\ 'autoload' : { | |
\ 'commands' : [{ 'name' : 'Unite', | |
\ 'complete' : 'customlist,unite#complete_source'}, | |
\ 'UniteWithCursorWord', 'UniteWithInput'] | |
\ }}) | |
call neobundle#config('vimfiler', { | |
\ 'lazy' : 1, | |
\ 'depends' : 'Shougo/unite.vim', | |
\ 'autoload' : { | |
\ 'commands' : [ | |
\ { 'name' : 'VimFiler', | |
\ 'complete' : 'customlist,vimfiler#complete' }, | |
\ { 'name' : 'VimFilerExplorer', | |
\ 'complete' : 'customlist,vimfiler#complete' }, | |
\ { 'name' : 'Edit', | |
\ 'complete' : 'customlist,vimfiler#complete' }, | |
\ { 'name' : 'Write', | |
\ 'complete' : 'customlist,vimfiler#complete' }, | |
\ 'Read', 'Source'], | |
\ 'mappings' : ['<Plug>(vimfiler_switch)'], | |
\ 'explorer' : 1, | |
\ } | |
\ }) | |
call neobundle#config('vimproc', { | |
\ 'build' : { | |
\ 'windows' : 'make -f make_mingw32.mak', | |
\ 'cygwin' : 'make -f make_cygwin.mak', | |
\ 'mac' : 'make -f make_mac.mak', | |
\ 'unix' : 'make -f make_unix.mak', | |
\ }, | |
\ }) | |
call neobundle#config('vinarise', { | |
\ 'lazy' : 1, | |
\ 'autoload' : { | |
\ 'commands' : 'Vinarise', | |
\ }}) | |
call neobundle#config('vital.vim', { | |
\ 'lazy' : 1, | |
\ 'autoload' : { | |
\ 'commands' : ['Vitalize'], | |
\ }}) | |
call neobundle#config('junkfile.vim', { | |
\ 'lazy' : 1, | |
\ 'autoload' : { | |
\ 'commands' : 'JunkfileOpen', | |
\ 'unite_sources' : ['junkfile', 'junkfile/new'], | |
\ }}) | |
call neobundle#config('vim-versions', { | |
\ 'lazy' : 1, | |
\ 'autoload' : { | |
\ 'commands' : 'UniteVersions'}, | |
\ }) | |
call neobundle#config('unite-outline', { | |
\ 'lazy' : 1, | |
\ 'autoload' : { | |
\ 'unite_sources' : 'outline'}, | |
\ }) | |
"}}} | |
" Disable menu.vim | |
if has('gui_running') | |
set guioptions=Mc | |
endif | |
" Disable GetLatestVimPlugin.vim | |
let g:loaded_getscriptPlugin = 1 | |
" Disable netrw.vim | |
let g:loaded_netrwPlugin = 1 | |
let g:loaded_matchparen = 0 | |
filetype plugin indent on | |
" Enable syntax color. | |
syntax enable | |
" Installation check. | |
NeoBundleCheck | |
"}}} | |
set encoding=utf-8 | |
set fileformat=unix | |
set fileformats=unix,dos,mac | |
set ignorecase | |
set smartcase | |
set noinfercase | |
set incsearch | |
set hlsearch | |
set wrapscan | |
set smarttab | |
set expandtab | |
set tabstop=4 | |
set shiftwidth=0 | |
set softtabstop=-1 | |
set shiftround | |
if has('unnamedplus') | |
set clipboard& clipboard+=unnamedplus | |
else | |
set clipboard& clipboard+=unnamed | |
endif | |
set backspace=indent,eol,start | |
set hidden | |
set nofoldenable | |
set foldmethod=marker | |
set foldcolumn=3 | |
set fillchars=vert:\| | |
set commentstring=%s | |
if exists('*FoldCCtext') | |
" Use FoldCCtext(). | |
set foldtext=FoldCCtext() | |
autocmd MyAutoCmd FileType * | |
\ if &filetype !=# 'help' | |
\ | setlocal foldtext=FoldCCtext() | |
\ | endif | |
endif | |
set grepprg=ack | |
" Keymapping timeout. | |
set timeout timeoutlen=3000 ttimeoutlen=100 | |
" CursorHold time. | |
set updatetime=1000 | |
set dir=~/.vim/tmp/swap | |
set viewdir=~/.vim/tmp/view | |
set undodir=~/.vim/tmp/undo | |
set undofile | |
set backupdir=~/.vim/tmp/backup | |
set backup | |
set viminfo+=n~/.vim/tmp/viminfo | |
set virtualedit=block | |
set keywordprg=:help | |
autocmd MyAutoCmd InsertLeave * | |
\ if &paste | set nopaste mouse=a | echo 'nopaste' | endif | | |
\ if &l:diff | diffupdate | endif | |
autocmd MyAutoCmd InsertLeave * if &l:diff | diffupdate | endif | |
autocmd MyAutoCmd BufWritePre * | |
\ call s:mkdir_as_necessary(expand('<afile>:p:h'), v:cmdbang) | |
function! s:mkdir_as_necessary(dir, force) | |
if !isdirectory(a:dir) && &l:buftype == '' && | |
\ (a:force || input(printf('"%s" does not exist. Create? [y/N]', | |
\ a:dir)) =~? '^y\%[es]$') | |
call mkdir(iconv(a:dir, &encoding, &termencoding), 'p') | |
endif | |
endfunction | |
set number | |
set list | |
set listchars=tab:¦-,trail:⋅,extends:»,precedes:«,nbsp:% | |
set wrap | |
set whichwrap+=h,l,<,>,[,],b,s,~ | |
set laststatus=2 | |
set showcmd | |
set showmode | |
set title | |
set titlelen=95 | |
let &titlestring=" | |
\ %{expand('%:p:.:~')}%(%m%r%w%) | |
\ %<\(%{".s:SID_PREFIX()."strwidthpart( | |
\ fnamemodify(&filetype ==# 'vimfiler' ? | |
\ substitute(b:vimfiler.current_dir, '.\\zs/$', '', '') : getcwd(), ':~'), | |
\ &columns-len(expand('%:p:.:~')))}\) - VIM" | |
" Set tabline. | |
function! s:my_tabline() "{{{ | |
let s = '' | |
for i in range(1, tabpagenr('$')) | |
let bufnrs = tabpagebuflist(i) | |
let bufnr = bufnrs[tabpagewinnr(i) - 1] " first window, first appears | |
let no = i " display 0-origin tabpagenr. | |
let mod = getbufvar(bufnr, '&modified') ? '!' : ' ' | |
" Use gettabvar(). | |
let title = | |
\ !exists('*gettabvar') ? | |
\ fnamemodify(bufname(bufnr), ':t') : | |
\ gettabvar(i, 'title') != '' ? | |
\ gettabvar(i, 'title') : | |
\ fnamemodify(gettabvar(i, 'cwd'), ':t') | |
let title = '[' . title . ']' | |
let s .= '%'.i.'T' | |
let s .= '%#' . (i == tabpagenr() ? 'TabLineSel' : 'TabLine') . '#' | |
let s .= no . ':' . title | |
let s .= mod | |
let s .= '%#TabLineFill# ' | |
endfor | |
let s .= '%#TabLineFill#%T%=%#TabLine#' | |
return s | |
endfunction "}}} | |
let &tabline = '%!'. s:SID_PREFIX() . 'my_tabline()' | |
set showtabline=2 | |
" Turn down a long line appointed in 'breakat' | |
set linebreak | |
set showbreak=>\ | |
set breakat=\ \ ;:,!? | |
" Do not display greetings message at the time of Vim start. | |
set shortmess=aTI | |
" Disable bell. | |
set t_vb= | |
set novisualbell | |
" Display candidate supplement. | |
set wcm=<Tab> | |
set wildmenu | |
set wildmode=longest,full | |
set wildignore=*.o,*.obj,*.ncb,*~ | |
set history=200 | |
set showfulltag | |
set wildoptions=tagfile | |
map <F7> :setlocal spell! spelllang=en_us<CR> | |
inoremap <F7> <C-\><C-O>:setlocal spelllang=en_us spell! spell?<CR> | |
set spellfile=~/.vim/tmp/spell/en.utf-8.add | |
set completeopt=menuone | |
set complete=. | |
set pumheight=20 | |
set report=0 | |
set nostartofline | |
set splitbelow | |
set splitright | |
set winwidth=30 | |
set winheight=1 | |
set cmdwinheight=5 | |
set noequalalways | |
set previewheight=8 | |
set helpheight=12 | |
set display=lastline | |
" Disable automatically insert comment. | |
autocmd MyAutoCmd FileType * | |
\ setl formatoptions-=ro | setl formatoptions+=mM | |
if v:version >= 703 | |
" For conceal. | |
set conceallevel=2 concealcursor=iv | |
" set colorcolumn=79 | |
endif | |
set viewoptions-=options viewoptions+=slash,unix | |
" Enable smart indent. | |
set autoindent smartindent | |
augroup MyAutoCmd | |
" Manage long Rakefile easily | |
autocmd BufNewfile,BufRead Rakefile set foldmethod=syntax foldnestmax=1 | |
" Close help and git window by pressing q. | |
autocmd FileType help,git-status,git-log,qf,J6uil_say,vimconsole, | |
\gitcommit,quickrun,qfreplace,ref,vcs-commit,vcs-status | |
\ nnoremap <buffer><silent> q :<C-u>call <sid>smart_close()<CR> | |
autocmd FileType * if (&readonly || !&modifiable) && !hasmapto('q', 'n') | |
\ | nnoremap <buffer><silent> q :<C-u>call <sid>smart_close()<CR>| endif | |
autocmd FileType gitcommit,qfreplace setlocal nofoldenable | |
autocmd FileType ref nnoremap <buffer> <TAB> <C-w>w | |
" Enable omni completion. | |
" autocmd FileType ada setlocal omnifunc=adacomplete#Complete | |
" autocmd FileType c setlocal omnifunc=ccomplete#Complete | |
autocmd FileType css setlocal omnifunc=csscomplete#CompleteCSS | |
autocmd FileType html,markdown setlocal omnifunc=htmlcomplete#CompleteTags | |
"autocmd FileType java setlocal omnifunc=javacomplete#Complete | |
" autocmd FileType php setlocal omnifunc=phpcomplete#CompletePHP | |
if has('python3') | |
autocmd FileType python setlocal omnifunc=python3complete#Complete | |
else | |
autocmd FileType python setlocal omnifunc=pythoncomplete#Complete | |
endif | |
"autocmd FileType ruby setlocal omnifunc=rubycomplete#Complete | |
"autocmd FileType sql setlocal omnifunc=sqlcomplete#Complete | |
autocmd FileType xml setlocal omnifunc=xmlcomplete#CompleteTags | |
autocmd FileType python setlocal foldmethod=indent | |
" autocmd FileType vim setlocal foldmethod=syntax | |
" Update filetype. | |
autocmd BufWritePost * | |
\ if &l:filetype ==# '' || exists('b:ftdetect') | |
\ | unlet! b:ftdetect | |
\ | filetype detect | |
\ | endif | |
" Improved include pattern. | |
autocmd FileType html | |
\ setlocal includeexpr=substitute(v:fname,'^\\/','','') | | |
\ setlocal path+=./;/ | |
autocmd FileType php setlocal path+=/usr/local/share/pear | |
autocmd FileType apache setlocal path+=./;/ | |
autocmd FileType armasm setlocal tabstop=8 noexpandtab | |
autocmd FileType asciidoc,gitcommit,markdown setlocal spell spelllang=en_us | |
autocmd FileType cmake setlocal tabstop=2 expandtab | |
autocmd FileType cs setlocal tabstop=2 noexpandtab | |
autocmd FileType make setlocal tabstop=8 noexpandtab | |
autocmd FileType man setlocal tabstop=8 expandtab | |
autocmd FileType markdown setlocal tabstop=4 expandtab | |
autocmd FileType python setlocal tabstop=2 expandtab nosmartindent | |
autocmd FileType ruby setlocal tabstop=2 expandtab autoindent | |
autocmd FileType sh setlocal tabstop=4 noexpandtab | |
autocmd FileType vim setlocal tabstop=2 expandtab | |
augroup END | |
" Python | |
let g:python_highlight_all = 1 | |
" XML | |
let g:xml_syntax_folding = 1 | |
" Vim | |
let g:vimsyntax_noerror = 1 | |
"let g:vim_indent_cont = 0 | |
" Bash | |
let g:is_bash = 1 | |
" Java | |
let g:java_highlight_functions = 'style' | |
let g:java_highlight_all=1 | |
let g:java_highlight_debug=1 | |
let g:java_allow_cpp_keywords=1 | |
let g:java_space_errors=1 | |
let g:java_highlight_functions=1 | |
" Vim script | |
" augroup: a | |
" function: f | |
" lua: l | |
" perl: p | |
" ruby: r | |
" python: P | |
" tcl: t | |
" mzscheme: m | |
let g:vimsyn_folding = 'af' | |
" Syntax highlight for user commands. | |
augroup syntax-highlight-extends | |
autocmd! | |
autocmd Syntax vim | |
\ call s:set_syntax_of_user_defined_commands() | |
augroup END | |
function! s:set_syntax_of_user_defined_commands() | |
redir => _ | |
silent! command | |
redir END | |
let command_names = join(map(split(_, '\n')[1:], | |
\ "matchstr(v:val, '[!\"b]*\\s\\+\\zs\\u\\w*\\ze')")) | |
if command_names == '' | return | endif | |
execute 'syntax keyword vimCommand ' . command_names | |
endfunction | |
" Clear modeline highlight. | |
autocmd MyAutoCmd VimEnter * highlight ModeMsg guifg=bg guibg=bg | |
"}}} | |
"--------------------------------------------------------------------------- | |
" Plugin:"{{{ | |
" | |
" Use neocomplete. | |
let g:neocomplete#enable_at_startup = 1 | |
" Use smartcase. | |
let g:neocomplete#enable_smart_case = 1 | |
let g:neocomplete#enable_ignore_case = 0 | |
" Set minimum syntax keyword length. | |
let g:neocomplete#sources#syntax#min_keyword_length = 3 | |
let g:neocomplete#lock_buffer_name_pattern = '\*ku\*' | |
call neocomplete#custom#source( | |
\ 'buffer', 'converters', [ | |
\ 'converter_remove_next_keyword', | |
\ 'converter_delimiter', | |
\ 'converter_abbr', ]) | |
" Define dictionary. | |
let g:neocomplete#sources#dictionary#dictionaries = { | |
\ 'default' : '', | |
\ 'scheme' : $HOME.'/.gosh_completions' | |
\ } | |
" Define keyword. | |
if !exists('g:neocomplete#keyword_patterns') | |
let g:neocomplete#keyword_patterns = {} | |
endif | |
let g:neocomplete#keyword_patterns['default'] = '\h\w*' | |
" Plugin key-mappings. | |
inoremap <expr><C-g> neocomplete#undo_completion() | |
inoremap <expr><C-l> neocomplete#complete_common_string() | |
" Recommended key-mappings. | |
" <CR>: close popup and save indent. | |
inoremap <silent> <CR> <C-r>=<SID>my_cr_function()<CR> | |
function! s:my_cr_function() | |
return pumvisible() ? neocomplete#close_popup() : "\<CR>" | |
endfunction | |
" <TAB>: completion. | |
inoremap <expr><TAB> pumvisible() ? "\<C-n>" : "\<TAB>" | |
inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<TAB>" | |
" <C-h>, <BS>: close popup and delete backword char. | |
inoremap <expr><C-h> neocomplete#smart_close_popup()."\<C-h>" | |
inoremap <expr><BS> neocomplete#smart_close_popup()."\<C-h>" | |
inoremap <expr><C-y> neocomplete#close_popup() | |
inoremap <expr><C-e> neocomplete#cancel_popup() | |
" Close popup by <Space>. | |
"inoremap <expr><Space> pumvisible() ? neocomplete#close_popup() : "\<Space>" | |
" Enable omni completion. | |
autocmd FileType css setlocal omnifunc=csscomplete#CompleteCSS | |
autocmd FileType html,markdown setlocal omnifunc=htmlcomplete#CompleteTags | |
autocmd FileType python setlocal omnifunc=pythoncomplete#Complete | |
autocmd FileType xml setlocal omnifunc=xmlcomplete#CompleteTags | |
" Enable heavy omni completion. | |
if !exists('g:neocomplete#sources#omni#input_patterns') | |
let g:neocomplete#sources#omni#input_patterns = {} | |
endif | |
if !exists('g:neocomplete#force_omni_input_patterns') | |
let g:neocomplete#force_omni_input_patterns = {} | |
endif | |
let g:neocomplete#sources#omni#input_patterns.php = | |
\ '[^. \t]->\%(\h\w*\)\?\|\h\w*::\%(\h\w*\)\?' | |
let g:neocomplete#sources#omni#input_patterns.c = | |
\ '[^.[:digit:] *\t]\%(\.\|->\)\%(\h\w*\)\?' | |
let g:neocomplete#sources#omni#input_patterns.cpp = | |
\ '[^.[:digit:] *\t]\%(\.\|->\)\%(\h\w*\)\?\|\h\w*::\%(\h\w*\)\?' | |
" For perlomni.vim setting. | |
" https://github.com/c9s/perlomni.vim | |
let g:neocomplete#sources#omni#input_patterns.perl = | |
\ '[^. \t]->\%(\h\w*\)\?\|\h\w*::\%(\h\w*\)\?' | |
" For smart TAB completion. | |
inoremap <expr><TAB> pumvisible() ? "\<C-n>" : | |
\ <SID>check_back_space() ? "\<TAB>" : | |
\ neocomplete#start_manual_complete() | |
function! s:check_back_space() "{{{ | |
let col = col('.') - 1 | |
return !col || getline('.')[col - 1] =~ '\s' | |
endfunction"}}} | |
" neosnippet.vim"{{{ | |
let g:neosnippet#snippets_directory = '~/.vim/bundle/vim-snippets/snippets/snippets, ~/.vim/snippets' | |
imap <C-k> <Plug>(neosnippet_expand_or_jump) | |
smap <C-k> <Plug>(neosnippet_expand_or_jump) | |
xmap <C-k> <Plug>(neosnippet_expand_target) | |
" SuperTab like snippets behavior. | |
imap <expr><TAB> neosnippet#expandable_or_jumpable() ? | |
\ "\<Plug>(neosnippet_expand_or_jump)" | |
\: pumvisible() ? "\<C-n>" : "\<TAB>" | |
smap <expr><TAB> neosnippet#expandable_or_jumpable() ? | |
\ "\<Plug>(neosnippet_expand_or_jump)" | |
\: "\<TAB>" | |
"}}} | |
" netrw.vim"{{{ | |
let g:netrw_list_hide= '*.swp' | |
nnoremap <silent> <BS> :<C-u>Explore<CR> | |
" Change default directory. | |
set browsedir=current | |
"}}} | |
" vinarise.vim"{{{ | |
let g:vinarise_enable_auto_detect = 1 | |
"}}} | |
" vim-versions{{{ | |
nnoremap <silent> [Space]gs :<C-u>UniteVersions status:!<CR> | |
"}}} | |
" unite.vim"{{{ | |
" The prefix key. | |
nnoremap [unite] <Nop> | |
xnoremap [unite] <Nop> | |
nmap ;u [unite] | |
xmap ;u [unite] | |
nnoremap [unite]u q:Unite<Space> | |
" nnoremap <silent> : :<C-u>Unite history/command command<CR> | |
nnoremap <expr><silent> ;b <SID>unite_build() | |
function! s:unite_build() | |
return ":\<C-u>Unite -buffer-name=build". tabpagenr() ." -no-quit build\<CR>" | |
endfunction | |
nnoremap <silent> ;o | |
\ :<C-u>Unite outline -start-insert -resume<CR> | |
nnoremap [unite]f :<C-u>Unite source<CR> | |
nnoremap <silent> ;t | |
\ :<C-u>UniteWithCursorWord -buffer-name=tag tag tag/include<CR> | |
xnoremap <silent> ;r | |
\ d:<C-u>Unite -buffer-name=register register history/yank<CR> | |
nnoremap <silent> ;w | |
\ :<C-u>UniteWithCursorWord -buffer-name=register | |
\ buffer file_mru bookmark file<CR> | |
nnoremap <silent> <C-k> | |
\ :<C-u>Unite change jump<CR> | |
nnoremap <silent> ;g | |
\ :<C-u>Unite grep -buffer-name=search -auto-preview -no-quit -resume<CR> | |
nnoremap <silent> ;r | |
\ :<C-u>Unite -buffer-name=register register history/yank<CR> | |
inoremap <silent><expr> <C-z> | |
\ unite#start_complete('register', { 'input': unite#get_cur_text() }) | |
" <C-t>: Tab pages | |
" nnoremap <silent><expr> <C-t> | |
" \ ":\<C-u>Unite -select=".(tabpagenr()-1)." tab\<CR>" | |
" <C-w>: Windows operation | |
" nnoremap <silent> <C-w> :<C-u>Unite window<CR> | |
if s:is_windows | |
nnoremap <silent> [Window]s | |
\ :<C-u>Unite -buffer-name=files -no-split -multi-line | |
\ jump_point file_point buffer_tab | |
\ file_rec:! file file/new file_mru<CR> | |
else | |
nnoremap <silent> [Window]s | |
\ :<C-u>Unite -buffer-name=files -no-split -multi-line | |
\ jump_point file_point buffer_tab | |
\ file_rec/async:! file file/new file_mru<CR> | |
endif | |
nnoremap <silent> [Window]w | |
\ :<C-u>Unite window<CR> | |
nnoremap <silent> [Space]b | |
\ :<C-u>UniteBookmarkAdd<CR> | |
" t: tags-and-searches "{{{ | |
" The prefix key. | |
nnoremap [Tag] <Nop> | |
nmap t [Tag] | |
" Jump. | |
" nnoremap [Tag]t <C-]> | |
nnoremap <silent><expr> [Tag]t &filetype == 'help' ? "\<C-]>" : | |
\ ":\<C-u>UniteWithCursorWord -buffer-name=tag tag tag/include\<CR>" | |
nnoremap <silent><expr> [Tag]p &filetype == 'help' ? | |
\ ":\<C-u>pop\<CR>" : ":\<C-u>Unite jump\<CR>" | |
" Tab jump | |
for n in range(1, 9) | |
execute 'nnoremap <silent> [Tag]'.n ':<C-u>tabnext'.n.'<CR>' | |
endfor | |
"}}} | |
" Execute help. | |
" nnoremap <silent> <C-h> :<C-u>Unite -buffer-name=help help<CR> | |
" Execute help by cursor keyword. | |
nnoremap <silent> g<C-h> :<C-u>UniteWithCursorWord help<CR> | |
" Search. | |
" nnoremap <silent> / | |
" \ :<C-u>Unite -buffer-name=search -no-split -start-insert line<CR> | |
nnoremap <expr> g/ <SID>smart_search_expr('g/', | |
\ ":\<C-u>Unite -buffer-name=search -auto-preview -start-insert line_migemo\<CR>") | |
nnoremap [Alt]/ g/ | |
" nnoremap <silent> ? | |
" \ :<C-u>Unite -buffer-name=search -auto-highlight -start-insert line:backward<CR> | |
" nnoremap <silent> * | |
" \ :<C-u>UniteWithCursorWord -no-split -buffer-name=search line<CR> | |
nnoremap [Alt]/ / | |
nnoremap [Alt]? ? | |
cnoremap <expr><silent><C-g> (getcmdtype() == '/') ? | |
\ "\<ESC>:Unite -buffer-name=search -no-split line -input=".getcmdline()."\<CR>" : "\<C-g>" | |
nnoremap <F1> :Unite file_mru<CR> | |
nnoremap <F2> :Unite buffer<CR> | |
nnoremap <F3> :Unite file<CR> | |
function! s:smart_search_expr(expr1, expr2) | |
return line('$') > 5000 ? a:expr1 : a:expr2 | |
endfunction | |
" nnoremap <silent> n | |
\ :<C-u>UniteResume search -no-start-insert<CR> | |
let g:unite_data_directory = '~/.vim/tmp/unite' | |
let g:unite_source_history_yank_enable = 1 | |
" For unite-alias. | |
let g:unite_source_alias_aliases = {} | |
let g:unite_source_alias_aliases.test = { | |
\ 'source' : 'file_rec', | |
\ 'args' : '~/', | |
\ } | |
let g:unite_source_alias_aliases.line_migemo = { | |
\ 'source' : 'line', | |
\ } | |
let g:unite_source_alias_aliases.message = { | |
\ 'source' : 'output', | |
\ 'args' : 'message', | |
\ } | |
let g:unite_source_alias_aliases.mes = { | |
\ 'source' : 'output', | |
\ 'args' : 'message', | |
\ } | |
let g:unite_source_alias_aliases.scriptnames = { | |
\ 'source' : 'output', | |
\ 'args' : 'scriptnames', | |
\ } | |
" For unite-menu. | |
let g:unite_source_menu_menus = {} | |
let g:unite_source_menu_menus.enc = { | |
\ 'description' : 'Open with a specific character code again.', | |
\ } | |
let g:unite_source_menu_menus.enc.command_candidates = [ | |
\ ['utf8', 'Utf8'], | |
\ ['iso2022jp', 'Iso2022jp'], | |
\ ['cp932', 'Cp932'], | |
\ ['euc', 'Euc'], | |
\ ['utf16', 'Utf16'], | |
\ ['utf16-be', 'Utf16be'], | |
\ ['jis', 'Jis'], | |
\ ['sjis', 'Sjis'], | |
\ ['unicode', 'Unicode'], | |
\ ] | |
nnoremap <silent> ;e :<C-u>Unite menu:enc<CR> | |
let g:unite_source_menu_menus.fenc = { | |
\ 'description' : 'Change file fenc option.', | |
\ } | |
let g:unite_source_menu_menus.fenc.command_candidates = [ | |
\ ['utf8', 'WUtf8'], | |
\ ['iso2022jp', 'WIso2022jp'], | |
\ ['cp932', 'WCp932'], | |
\ ['euc', 'WEuc'], | |
\ ['utf16', 'WUtf16'], | |
\ ['utf16-be', 'WUtf16be'], | |
\ ['jis', 'WJis'], | |
\ ['sjis', 'WSjis'], | |
\ ['unicode', 'WUnicode'], | |
\ ] | |
nnoremap <silent> ;f :<C-u>Unite menu:fenc<CR> | |
let g:unite_source_menu_menus.ff = { | |
\ 'description' : 'Change file format option.', | |
\ } | |
let g:unite_source_menu_menus.ff.command_candidates = { | |
\ 'unix' : 'WUnix', | |
\ 'dos' : 'WDos', | |
\ 'mac' : 'WMac', | |
\ } | |
nnoremap <silent> ;w :<C-u>Unite menu:ff<CR> | |
let g:unite_source_menu_menus.unite = { | |
\ 'description' : 'Start unite sources', | |
\ } | |
let g:unite_source_menu_menus.unite.command_candidates = { | |
\ 'history' : 'Unite history/command', | |
\ 'quickfix' : 'Unite qflist -no-quit', | |
\ 'resume' : 'Unite -buffer-name=resume resume', | |
\ 'directory' : 'Unite -buffer-name=files '. | |
\ '-default-action=lcd directory_mru', | |
\ 'mapping' : 'Unite mapping', | |
\ 'message' : 'Unite output:message', | |
\ 'scriptnames': 'Unite output:scriptnames', | |
\ } | |
nnoremap <silent> ;u :<C-u>Unite menu:unite -resume<CR> | |
let bundle = neobundle#get('unite.vim') | |
function! bundle.hooks.on_source(bundle) | |
autocmd MyAutoCmd FileType unite call s:unite_my_settings() | |
call unite#custom#profile('action', 'context', {'start_insert' : 1}) | |
" Set "-no-quit" automatically in grep unite source. | |
call unite#custom#profile('source/grep', 'context', {'no_quit' : 1}) | |
" migemo. | |
call unite#custom#source('line_migemo', 'matchers', 'matcher_migemo') | |
call unite#custom#source('file_rec', 'sorters', 'sorter_reverse') | |
" Custom filters."{{{ | |
call unite#custom#source( | |
\ 'buffer,file_rec,file_rec/async,file_mru', 'matchers', | |
\ ['converter_tail', 'matcher_fuzzy']) | |
call unite#custom#source( | |
\ 'file', 'matchers', | |
\ ['matcher_fuzzy', 'matcher_hide_hidden_files']) | |
call unite#custom#source( | |
\ 'file_rec/async,file_mru', 'converters', | |
\ ['converter_file_directory']) | |
call unite#filters#sorter_default#use(['sorter_rank']) | |
"}}} | |
function! s:unite_my_settings() "{{{ | |
" Directory partial match. | |
call unite#custom#alias('file', 'h', 'left') | |
call unite#custom#default_action('directory', 'narrow') | |
" call unite#custom#default_action('file', 'my_tabopen') | |
call unite#custom#default_action('versions/git/status', 'commit') | |
" call unite#custom#default_action('directory', 'cd') | |
" Custom actions."{{{ | |
let my_tabopen = { | |
\ 'description' : 'my tabopen items', | |
\ 'is_selectable' : 1, | |
\ } | |
function! my_tabopen.func(candidates) "{{{ | |
call unite#take_action('tabopen', a:candidates) | |
let dir = isdirectory(a:candidates[0].word) ? | |
\ a:candidates[0].word : fnamemodify(a:candidates[0].word, ':p:h') | |
execute g:unite_kind_openable_lcd_command '`=dir`' | |
endfunction"}}} | |
call unite#custom#action('file,buffer', 'tabopen', my_tabopen) | |
unlet my_tabopen | |
"}}} | |
" Overwrite settings. | |
imap <buffer> <BS> <Plug>(unite_delete_backward_path) | |
imap <buffer> jj <Plug>(unite_insert_leave) | |
imap <buffer><expr> j unite#smart_map('j', '') | |
imap <buffer> <TAB> <Plug>(unite_select_next_line) | |
imap <buffer> <C-w> <Plug>(unite_delete_backward_path) | |
imap <buffer> ' <Plug>(unite_quick_match_default_action) | |
nmap <buffer> ' <Plug>(unite_quick_match_default_action) | |
imap <buffer><expr> x | |
\ unite#smart_map('x', "\<Plug>(unite_quick_match_choose_action)") | |
nmap <buffer> x <Plug>(unite_quick_match_choose_action) | |
nmap <buffer> cd <Plug>(unite_quick_match_default_action) | |
nmap <buffer> <C-z> <Plug>(unite_toggle_transpose_window) | |
imap <buffer> <C-z> <Plug>(unite_toggle_transpose_window) | |
imap <buffer> <C-y> <Plug>(unite_narrowing_path) | |
nmap <buffer> <C-y> <Plug>(unite_narrowing_path) | |
" nmap <buffer> <C-j> <Plug>(unite_toggle_auto_preview) | |
" nmap <buffer> <C-r> <Plug>(unite_narrowing_input_history) | |
" imap <buffer> <C-r> <Plug>(unite_narrowing_input_history) | |
nmap <silent><buffer> <Tab> :call <SID>NextWindow()<CR> | |
nnoremap <silent><buffer><expr> l | |
\ unite#smart_map('l', unite#do_action('default')) | |
nmap <buffer> <C-e> <Plug>(unite_narrowing_input_history) | |
let unite = unite#get_current_unite() | |
if unite.buffer_name =~# '^search' | |
nnoremap <silent><buffer><expr> r unite#do_action('replace') | |
else | |
nnoremap <silent><buffer><expr> r unite#do_action('rename') | |
endif | |
nnoremap <silent><buffer><expr> cd unite#do_action('lcd') | |
nnoremap <buffer><expr> S unite#mappings#set_current_filters( | |
\ empty(unite#mappings#get_current_filters()) ? ['sorter_reverse'] : []) | |
endfunction"}}} | |
" Variables. | |
let g:unite_enable_split_vertically = 0 | |
let g:unite_winheight = 20 | |
let g:unite_enable_start_insert = 0 | |
let g:unite_enable_short_source_names = 1 | |
let g:unite_cursor_line_highlight = 'TabLineSel' | |
" let g:unite_abbr_highlight = 'TabLine' | |
" let g:unite_source_file_mru_time_format = '' | |
let g:unite_source_file_mru_filename_format = ':~:.' | |
let g:unite_source_file_mru_limit = 300 | |
" let g:unite_source_directory_mru_time_format = '' | |
let g:unite_source_directory_mru_limit = 300 | |
if s:is_windows | |
else | |
" Like Textmate icons. | |
let g:unite_marked_icon = '✗' | |
" Prompt choices. | |
"let g:unite_prompt = '❫ ' | |
let g:unite_prompt = '» ' | |
endif | |
if executable('ag') | |
" Use ag in unite grep source. | |
let g:unite_source_grep_command = 'ag' | |
let g:unite_source_grep_default_opts = | |
\ '--line-numbers --nocolor --nogroup --hidden --ignore ' . | |
\ '''.hg'' --ignore ''.svn'' --ignore ''.git'' --ignore ''.bzr''' | |
let g:unite_source_grep_recursive_opt = '' | |
elseif executable('jvgrep') | |
" For jvgrep. | |
let g:unite_source_grep_command = 'jvgrep' | |
let g:unite_source_grep_default_opts = '--exclude ''\.(git|svn|hg|bzr)''' | |
let g:unite_source_grep_recursive_opt = '-R' | |
elseif executable('ack-grep') | |
" For ack. | |
let g:unite_source_grep_command = 'ack-grep' | |
let g:unite_source_grep_default_opts = '--no-heading --no-color -a' | |
let g:unite_source_grep_recursive_opt = '' | |
endif | |
let g:unite_build_error_icon = $DOTVIM . '/signs/err.' | |
\ . (s:is_windows ? 'bmp' : 'png') | |
let g:unite_build_warning_icon = $DOTVIM . '/signs/warn.' | |
\ . (s:is_windows ? 'bmp' : 'png') | |
endfunction | |
unlet bundle | |
"}}} | |
" smartword.vim"{{{ | |
" Replace w and others with smartword-mappings | |
nmap w <Plug>(smartword-w) | |
nmap b <Plug>(smartword-b) | |
nmap ge <Plug>(smartword-ge) | |
xmap w <Plug>(smartword-w) | |
xmap b <Plug>(smartword-b) | |
" Operator pending mode. | |
omap <Leader>w <Plug>(smartword-w) | |
omap <Leader>b <Plug>(smartword-b) | |
omap <Leader>ge <Plug>(smartword-ge) | |
"}}} | |
" camlcasemotion.vim"{{{ | |
nmap <silent> [Alt]w <Plug>CamelCaseMotion_w | |
xmap <silent> [Alt]w <Plug>CamelCaseMotion_w | |
omap <silent> [Alt]w <Plug>CamelCaseMotion_w | |
nmap <silent> [Alt]b <Plug>CamelCaseMotion_b | |
xmap <silent> [Alt]b <Plug>CamelCaseMotion_b | |
omap <silent> [Alt]b <Plug>CamelCaseMotion_b | |
""}}} | |
" smarttill.vim"{{{ | |
xmap q <Plug>(smarttill-t) | |
xmap Q <Plug>(smarttill-T) | |
" Operator pending mode. | |
omap q <Plug>(smarttill-t) | |
omap Q <Plug>(smarttill-T) | |
"}}} | |
" python.vim | |
let python_highlight_all = 1 | |
" ref.vim"{{{ | |
let bundle = neobundle#get('vim-ref') | |
function! bundle.hooks.on_source(bundle) | |
let g:ref_use_vimproc = 1 | |
if s:is_windows | |
let g:ref_refe_encoding = 'cp932' | |
else | |
let g:ref_refe_encoding = 'euc-jp' | |
endif | |
" ref-lynx. | |
if s:is_windows | |
let lynx = 'C:/lynx/lynx.exe' | |
let cfg = 'C:/lynx/lynx.cfg' | |
let g:ref_lynx_cmd = s:lynx.' -cfg='.s:cfg.' -dump -nonumbers %s' | |
let g:ref_alc_cmd = s:lynx.' -cfg='.s:cfg.' -dump %s' | |
endif | |
let g:ref_lynx_use_cache = 1 | |
let g:ref_lynx_start_linenumber = 0 " Skip. | |
let g:ref_lynx_hide_url_number = 0 | |
autocmd MyAutoCmd FileType ref call s:ref_my_settings() | |
function! s:ref_my_settings() "{{{ | |
" Overwrite settings. | |
nmap <buffer> [Tag]t <Plug>(ref-keyword) | |
nmap <buffer> [Tag]p <Plug>(ref-back) | |
endfunction"}}} | |
endfunction | |
unlet bundle | |
"}}} | |
" vimfiler.vim"{{{ | |
nmap [Space]v <Plug>(vimfiler_switch) | |
nnoremap <silent> [Space]v :<C-u>VimFiler -find<CR> | |
nnoremap [Space]ff :<C-u>VimFilerExplorer<CR> | |
nnoremap <F4> :VimFilerExplorer<CR> | |
let bundle = neobundle#get('vimfiler') | |
function! bundle.hooks.on_source(bundle) | |
let g:vimfiler_enable_clipboard = 0 | |
let g:vimfiler_safe_mode_by_default = 0 | |
let g:vimfiler_as_default_explorer = 1 | |
let g:vimfiler_detect_drives = s:is_windows ? [ | |
\ 'C:/', 'D:/', 'E:/', 'F:/', 'G:/', 'H:/', 'I:/', | |
\ 'J:/', 'K:/', 'L:/', 'M:/', 'N:/'] : | |
\ split(glob('/mnt/*'), '\n') + split(glob('/media/*'), '\n') + | |
\ split(glob('/Users/*'), '\n') | |
" %p : full path | |
" %d : current directory | |
" %f : filename | |
" %F : filename removed extensions | |
" %* : filenames | |
" %# : filenames fullpath | |
let g:vimfiler_sendto = { | |
\ 'unzip' : 'unzip %f', | |
\ 'zip' : 'zip -r %F.zip %*', | |
\ 'Inkscape' : 'inkspace', | |
\ 'GIMP' : 'gimp %*', | |
\ 'gedit' : 'gedit', | |
\ } | |
if s:is_windows | |
" Use trashbox. | |
let g:unite_kind_file_use_trashbox = 1 | |
else | |
" Like Textmate icons. | |
let g:vimfiler_tree_leaf_icon = ' ' | |
let g:vimfiler_tree_opened_icon = '▾' | |
let g:vimfiler_tree_closed_icon = '▸' | |
let g:vimfiler_file_icon = ' ' | |
let g:vimfiler_readonly_file_icon = '✗' | |
let g:vimfiler_marked_file_icon = '✓' | |
endif | |
" let g:vimfiler_readonly_file_icon = '[O]' | |
let g:vimfiler_data_directory = '~/.vim/tmp/vimfiler' | |
let g:vimfiler_quick_look_command = | |
\ s:is_windows ? 'maComfort.exe -ql' : | |
\ 'gloobus-preview' | |
let g:vimfiler_explorer_columns = '' | |
autocmd MyAutoCmd FileType vimfiler call s:vimfiler_my_settings() | |
function! s:vimfiler_my_settings() "{{{ | |
call vimfiler#set_execute_file('vim', 'vim') | |
call vimfiler#set_execute_file('txt', 'vim') | |
" Overwrite settings. | |
nnoremap <silent><buffer> J | |
\ <C-u>:Unite -buffer-name=files -default-action=lcd directory_mru<CR> | |
" Call sendto. | |
" nnoremap <buffer> - <C-u>:Unite sendto<CR> | |
" setlocal cursorline | |
nmap <buffer> O <Plug>(vimfiler_sync_with_another_vimfiler) | |
nnoremap <silent><buffer><expr> gy vimfiler#do_action('tabopen') | |
nmap <buffer> p <Plug>(vimfiler_quick_look) | |
nmap <buffer> <Tab> <Plug>(vimfiler_switch_to_other_window) | |
" Migemo search. | |
if !empty(unite#get_filters('matcher_migemo')) | |
nnoremap <silent><buffer><expr> / line('$') > 10000 ? 'g/' : | |
\ ":\<C-u>Unite -buffer-name=search -start-insert line_migemo\<CR>" | |
endif | |
" One key file operation. | |
" nmap <buffer> c <Plug>(vimfiler_mark_current_line)<Plug>(vimfiler_copy_file) | |
" nmap <buffer> m <Plug>(vimfiler_mark_current_line)<Plug>(vimfiler_move_file) | |
" nmap <buffer> d <Plug>(vimfiler_mark_current_line)<Plug>(vimfiler_delete_file) | |
setl nonumber | |
" nmap <buffer> <Enter> <Plug>(vimfiler_edit_file) | |
" nmap <buffer> e <Plug>(vimfiler_execute) | |
nmap <buffer> <C-l> <C-w>l | |
" nmap <buffer> <2-LeftMouse> | |
" \ :<C-u>call <Plug>(vimfiler_expand_tree)<CR> | |
endfunction"}}} | |
endfunction | |
unlet bundle | |
"}}} | |
" surround.vim"{{{ | |
let g:surround_no_mappings = 1 | |
autocmd MyAutoCmd FileType * call s:define_surround_keymappings() | |
function! s:define_surround_keymappings() | |
if !&l:modifiable | |
silent! nunmap <buffer> ds | |
silent! nunmap <buffer> cs | |
silent! nunmap <buffer> ys | |
silent! nunmap <buffer> yS | |
else | |
nmap <buffer> ds <Plug>Dsurround | |
nmap <buffer> cs <Plug>Csurround | |
nmap <buffer> ys <Plug>Ysurround | |
nmap <buffer> yS <Plug>YSurround | |
endif | |
endfunction | |
"}}} | |
" qfreplace.vim | |
autocmd MyAutoCmd FileType qf nnoremap <buffer> r :<C-u>Qfreplace<CR> | |
" open-browser.vim"{{{ | |
nmap gs <Plug>(open-browser-wwwsearch) | |
let bundle = neobundle#get('open-browser.vim') | |
function! bundle.hooks.on_source(bundle) | |
nnoremap <Plug>(open-browser-wwwsearch) | |
\ :<C-u>call <SID>www_search()<CR> | |
function! s:www_search() | |
let search_word = input('Please input search word: ', '', | |
\ 'customlist,wwwsearch#cmd_Wwwsearch_complete') | |
if search_word != '' | |
execute 'OpenBrowserSearch' escape(search_word, '"') | |
endif | |
endfunction | |
endfunction | |
unlet bundle | |
"}}} | |
" caw.vim"{{{ | |
autocmd MyAutoCmd FileType * call s:init_caw() | |
function! s:init_caw() | |
if !&l:modifiable | |
silent! nunmap <buffer> gc | |
silent! xunmap <buffer> gc | |
silent! nunmap <buffer> gcc | |
silent! xunmap <buffer> gcc | |
return | |
endif | |
nmap <buffer> gc <Plug>(caw:prefix) | |
xmap <buffer> gc <Plug>(caw:prefix) | |
nmap <buffer> gcc <Plug>(caw:i:toggle) | |
xmap <buffer> gcc <Plug>(caw:i:toggle) | |
endfunction | |
"}}} | |
" autodate.vim"{{{ | |
let autodate_format = '%d %3m %Y' | |
let autodate_keyword_pre = 'Last \%(Change\|Modified\):' | |
"}}} | |
" fontzoom.vim"{{{ | |
nmap + <Plug>(fontzoom-larger) | |
nmap _ <Plug>(fontzoom-smaller) | |
"}}} | |
" Gundo.vim | |
nnoremap U :<C-u>GundoToggle<CR> | |
" Operator-replace. | |
nmap R <Plug>(operator-replace) | |
xmap R <Plug>(operator-replace) | |
xmap p <Plug>(operator-replace) | |
" restart.vim {{{ | |
let g:restart_save_window_values = 0 | |
nnoremap <silent> [Space]re :<C-u>Restart<CR> | |
"}}} | |
if neobundle#is_installed('accelerated-jk') | |
" accelerated-jk | |
nmap <silent>j <Plug>(accelerated_jk_gj) | |
nmap gj j | |
nmap <silent>k <Plug>(accelerated_jk_gk) | |
nmap gk k | |
endif | |
" tabpagecd | |
autocmd MyAutoCmd TabEnter * NeoBundleSource vim-tabpagecd | |
" altercmd.vim{{{ | |
let bundle = neobundle#get('vim-altercmd') | |
function! bundle.hooks.on_source(bundle) | |
call altercmd#load() | |
AlterCommand <cmdwin> u[nite] Unite | |
AlterCommand u[nite] Unite | |
AlterCommand <cmdwin> u[nite] Unite | |
AlterCommand u[nite] Unite | |
AlterCommand <cmdwin> e[dit] Edit | |
AlterCommand e[dit] Edit | |
AlterCommand <cmdwin> r[ead] Read | |
AlterCommand r[ead] Read | |
AlterCommand <cmdwin> s[ource] Source | |
AlterCommand s[ource] Source | |
AlterCommand <cmdwin> w[rite] Write | |
AlterCommand w[rite] Write | |
endfunction | |
unlet bundle | |
"}}} | |
" switch.vim{{{ | |
" http://www.vimninjas.com/2012/09/12/switch/ | |
let g:variable_style_switch_definitions = [ | |
\ { | |
\ 'f': { | |
\ 'foo': 'bar' | |
\ }, | |
\ | |
\ 'b': { | |
\ 'bar': 'foo' | |
\ }, | |
\ } | |
\ ] | |
" nnoremap <silent> + :call switch#Switch(g:variable_style_switch_definitions)<CR> | |
nnoremap <silent> ! :Switch<cr> | |
"}}} | |
" vim-niceblock | |
" Improved visual selection. | |
xmap I <Plug>(niceblock-I) | |
xmap A <Plug>(niceblock-A) | |
"}}} | |
"--------------------------------------------------------------------------- | |
" Key-mappings: "{{{ | |
" | |
" Visual search mappings | |
function! s:VSetSearch() | |
let temp = @@ | |
norm! gvy | |
let @/ = '\V' . substitute(escape(@@, '\'), '\n', '\\n', 'g') | |
let @@ = temp | |
endfunction | |
vnoremap * :<C-u>call <SID>VSetSearch()<CR>//<CR> | |
vnoremap # :<C-u>call <SID>VSetSearch()<CR>??<CR> | |
nnoremap <Leader>l :nohlsearch<CR> | |
nnoremap <C-j> <C-W>j | |
nnoremap <C-k> <C-W>k | |
nnoremap <C-h> <C-W>h | |
nnoremap <C-l> <C-W>l | |
nnoremap <C-Left> <C-w>h | |
nnoremap <C-Up> <C-w>j | |
nnoremap <C-Down> <C-w>k | |
nnoremap <C-Right> <C-w>l | |
map <F10> :set invpaste<CR> | |
set pastetoggle=<F10> | |
" Use <C-Space>. | |
map <C-Space> <C-@> | |
cmap <C-Space> <C-@> | |
" Visual mode keymappings: "{{{ | |
" <TAB>: indent. | |
xnoremap <TAB> > | |
" <S-TAB>: unindent. | |
xnoremap <S-TAB> < | |
" Indent | |
nnoremap > >> | |
nnoremap < << | |
xnoremap > >gv | |
xnoremap < <gv | |
xnoremap <silent> y "*y:let [@+,@"]=[@*,@*]<CR> | |
"}}} | |
" Insert mode keymappings: "{{{ | |
" <C-t>: insert tab. | |
" inoremap <C-t> <C-v><TAB> | |
" <C-d>: delete char. | |
" inoremap <C-d> <Del> | |
" <C-a>: move to head. | |
" inoremap <silent><C-a> <C-o>^ | |
" Enable undo <C-w> and <C-u>. | |
" inoremap <C-w> <C-g>u<C-w> | |
" inoremap <C-u> <C-g>u<C-u> | |
if has('gui_running') | |
inoremap <ESC> <ESC> | |
endif | |
"}}} | |
" Command-line mode keymappings:"{{{ | |
" <C-a>, A: move to head. | |
cnoremap <C-a> <Home> | |
" <C-b>: previous char. | |
cnoremap <C-b> <Left> | |
" <C-d>: delete char. | |
cnoremap <C-d> <Del> | |
" <C-e>, E: move to end. | |
cnoremap <C-e> <End> | |
" <C-f>: next char. | |
cnoremap <C-f> <Right> | |
" <C-n>: next history. | |
cnoremap <C-n> <Down> | |
" <C-p>: previous history. | |
cnoremap <C-p> <Up> | |
" <C-k>, K: delete to end. | |
" cnoremap <C-k> <C-\>e getcmdpos() == 1 ? | |
\ '' : getcmdline()[:getcmdpos()-2]<CR> | |
" <C-y>: paste. | |
cnoremap <C-y> <C-r>* | |
"}}} | |
" Command line buffer."{{{ | |
nnoremap <SID>(command-line-enter) q: | |
xnoremap <SID>(command-line-enter) q: | |
nnoremap <SID>(command-line-norange) q:<C-u> | |
nmap ;; <SID>(command-line-enter) | |
xmap ;; <SID>(command-line-enter) | |
autocmd MyAutoCmd CmdwinEnter * call s:init_cmdwin() | |
autocmd MyAutoCmd CmdwinLeave * let g:neocomplete_enable_auto_select = 1 | |
function! s:init_cmdwin() | |
NeoBundleSource vim-altercmd | |
let g:neocomplete_enable_auto_select = 0 | |
let b:neocomplete_sources_list = ['vim_complete'] | |
nnoremap <buffer><silent> q :<C-u>quit<CR> | |
nnoremap <buffer><silent> <TAB> :<C-u>quit<CR> | |
inoremap <buffer><expr><CR> neocomplete#close_popup()."\<CR>" | |
inoremap <buffer><expr><C-h> col('.') == 1 ? | |
\ "\<ESC>:quit\<CR>" : neocomplete#cancel_popup()."\<C-h>" | |
inoremap <buffer><expr><BS> col('.') == 1 ? | |
\ "\<ESC>:quit\<CR>" : neocomplete#cancel_popup()."\<C-h>" | |
" Completion. | |
inoremap <buffer><expr><TAB> pumvisible() ? | |
\ "\<C-n>" : <SID>check_back_space() ? "\<TAB>" : "\<C-x>\<C-u>\<C-p>" | |
startinsert! | |
endfunction"}}} | |
" [Space]: Other useful commands "{{{ | |
" Smart space mapping. | |
" Notice: when starting other <Space> mappings in noremap, disappeared [Space]. | |
nmap <Space> [Space] | |
xmap <Space> [Space] | |
nnoremap [Space] <Nop> | |
xnoremap [Space] <Nop> | |
" Toggle relativenumber. | |
nnoremap <silent> [Space]. | |
\ :<C-u>call ToggleOption('relativenumber')<CR> | |
nnoremap <silent> [Space]p | |
\ :<C-u>call ToggleOption('paste')<CR>:set mouse=<CR> | |
" Toggle highlight. | |
nnoremap <silent> [Space]/ | |
\ :<C-u>call ToggleOption('hlsearch')<CR> | |
" Toggle cursorline. | |
nnoremap <silent> [Space]cl | |
\ :<C-u>call ToggleOption('cursorline')<CR> | |
" Set autoread. | |
nnoremap [Space]ar | |
\ :<C-u>setlocal autoread<CR> | |
" Output encoding information. | |
nnoremap <silent> [Space]en | |
\ :<C-u>setlocal encoding? termencoding? fenc? fencs?<CR> | |
" Set spell check. | |
nnoremap [Space]sp | |
\ :<C-u>call ToggleOption('spell')<CR> | |
nnoremap [Space]w | |
\ :<C-u>call ToggleOption('wrap')<CR> | |
" Echo syntax name. | |
nnoremap [Space]sy | |
\ :<C-u>echo synIDattr(synID(line('.'), col('.'), 1), "name")<CR> | |
" Easily edit .vimrc and .gvimrc "{{{ | |
nnoremap <silent> [Space]ev :<C-u>edit $MYVIMRC<CR> | |
nnoremap <silent> [Space]eg :<C-u>edit $MYGVIMRC<CR> | |
" Load .gvimrc after .vimrc edited at GVim. | |
nnoremap <silent> [Space]rv :<C-u>source $MYVIMRC \| | |
\ if has('gui_running') \| | |
\ source $MYGVIMRC \| | |
\ endif \| echo "source $MYVIMRC"<CR> | |
nnoremap <silent> [Space]rg | |
\ :<C-u>source $MYGVIMRC \| | |
\ echo "source $MYGVIMRC"<CR> | |
"}}} | |
" Useful save mappings. | |
nnoremap <silent> <Leader><Leader> :<C-u>update<CR> | |
" Change current directory. | |
nnoremap <silent> [Space]cd :<C-u>call <SID>cd_buffer_dir()<CR> | |
function! s:cd_buffer_dir() "{{{ | |
let filetype = getbufvar(bufnr('%'), '&filetype') | |
if filetype ==# 'vimfiler' | |
let dir = getbufvar(bufnr('%'), 'vimfiler').current_dir | |
else | |
let dir = isdirectory(bufname('%')) ? bufname('%') : fnamemodify(bufname('%'), ':p:h') | |
endif | |
cd `=dir` | |
endfunction"}}} | |
" Delete windows ^M codes. | |
nnoremap <silent> [Space]<C-m> mmHmt:<C-u>%s/\r$//ge<CR>'tzt'm | |
" Delete spaces before newline. | |
nnoremap <silent> [Space]ss mmHmt:<C-u>%s/<Space>$//ge<CR>`tzt`m | |
" Easily syntax change. | |
nnoremap <silent> [Space]ft :<C-u>Unite -start-insert filetype<CR> | |
" Exchange gj and gk to j and k. "{{{ | |
command! -nargs=? -bar -bang ToggleGJK call s:ToggleGJK() | |
nnoremap <silent> [Space]gj :<C-u>ToggleGJK<CR> | |
xnoremap <silent> [Space]gj :<C-u>ToggleGJK<CR> | |
function! s:ToggleGJK() | |
if exists('b:enable_mapping_gjk') && b:enable_mapping_gjk | |
let b:enable_mapping_gjk = 0 | |
noremap <buffer> j j | |
noremap <buffer> k k | |
noremap <buffer> gj gj | |
noremap <buffer> gk gk | |
xnoremap <buffer> j j | |
xnoremap <buffer> k k | |
xnoremap <buffer> gj gj | |
xnoremap <buffer> gk gk | |
else | |
let b:enable_mapping_gjk = 1 | |
noremap <buffer> j gj | |
noremap <buffer> k gk | |
noremap <buffer> gj j | |
noremap <buffer> gk k | |
xnoremap <buffer> j gj | |
xnoremap <buffer> k gk | |
xnoremap <buffer> gj j | |
xnoremap <buffer> gk k | |
endif | |
endfunction"}}} | |
" Change tab width. "{{{ | |
nnoremap <silent> [Space]t2 :<C-u>setl shiftwidth=2 softtabstop=2<CR> | |
nnoremap <silent> [Space]t4 :<C-u>setl shiftwidth=4 softtabstop=4<CR> | |
nnoremap <silent> [Space]t8 :<C-u>setl shiftwidth=8 softtabstop=8<CR> | |
"}}} | |
"}}} | |
" s: Windows and buffers(High priority) "{{{ | |
" The prefix key. | |
nnoremap [Window] <Nop> | |
nmap s [Window] | |
nnoremap <silent> [Window]p :<C-u>call <SID>split_nicely()<CR> | |
nnoremap <silent> [Window]v :<C-u>vsplit<CR> | |
nnoremap <silent> [Window]c :<C-u>call <sid>smart_close()<CR> | |
nnoremap <silent> - :<C-u>call <SID>smart_close()<CR> | |
nnoremap <silent> [Window]o :<C-u>only<CR> | |
nnoremap <silent> [Window]b :<C-u>Thumbnail<CR> | |
" A .vimrc snippet that allows you to move around windows beyond tabs | |
nnoremap <silent> <Tab> :call <SID>NextWindow()<CR> | |
nnoremap <silent> <S-Tab> :call <SID>PreviousWindowOrTab()<CR> | |
function! s:smart_close() | |
if winnr('$') != 1 | |
close | |
endif | |
endfunction | |
function! s:NextWindow() | |
if winnr('$') == 1 | |
silent! normal! ``z. | |
else | |
wincmd w | |
endif | |
endfunction | |
function! s:NextWindowOrTab() | |
if tabpagenr('$') == 1 && winnr('$') == 1 | |
call s:split_nicely() | |
elseif winnr() < winnr("$") | |
wincmd w | |
else | |
tabnext | |
1wincmd w | |
endif | |
endfunction | |
function! s:PreviousWindowOrTab() | |
if winnr() > 1 | |
wincmd W | |
else | |
tabprevious | |
execute winnr("$") . "wincmd w" | |
endif | |
endfunction | |
nnoremap <silent> [Window]<Space> :<C-u>call <SID>ToggleSplit()<CR> | |
" If window isn't splited, split buffer. | |
function! s:ToggleSplit() | |
let prev_name = winnr() | |
silent! wincmd w | |
if prev_name == winnr() | |
SplitNicely | |
else | |
call s:smart_close() | |
endif | |
endfunction | |
" Split nicely."{{{ | |
command! SplitNicely call s:split_nicely() | |
function! s:split_nicely() | |
" Split nicely. | |
if winwidth(0) > 2 * &winwidth | |
vsplit | |
else | |
split | |
endif | |
wincmd p | |
endfunction | |
"}}} | |
" Delete current buffer."{{{ | |
nnoremap <silent> [Window]d :<C-u>call <SID>CustomBufferDelete(0)<CR> | |
" Force delete current buffer. | |
nnoremap <silent> [Window]D :<C-u>call <SID>CustomBufferDelete(1)<CR> | |
function! s:CustomBufferDelete(is_force) | |
let current = bufnr('%') | |
call unite#util#alternate_buffer() | |
if a:is_force | |
silent! execute 'bdelete! ' . current | |
else | |
silent! execute 'bdelete ' . current | |
endif | |
endfunction | |
"}}} | |
" JunkFile | |
" nnoremap <silent> [Window]e :<C-u>JunkfileOpen<CR> | |
nnoremap <silent> [Window]e :<C-u>Unite junkfile/new junkfile -start-insert<CR> | |
command! -nargs=0 JunkfileDiary call junkfile#open_immediately( | |
\ strftime('%Y-%m-%d.md')) | |
"}}} | |
" e: Change basic commands "{{{ | |
" The prefix key. | |
nnoremap [Alt] <Nop> | |
xnoremap [Alt] <Nop> | |
nmap e [Alt] | |
xmap e [Alt] | |
nnoremap [Alt]e e | |
xnoremap [Alt]e e | |
" Indent paste. | |
nnoremap <silent> [Alt]p o<Esc>pm``[=`]``^ | |
xnoremap <silent> [Alt]p o<Esc>pm``[=`]``^ | |
nnoremap <silent> [Alt]P O<Esc>Pm``[=`]``^ | |
xnoremap <silent> [Alt]P O<Esc>Pm``[=`]``^ | |
" Insert blank line. | |
nnoremap <silent> [Alt]o o<Space><BS><ESC> | |
nnoremap <silent> [Alt]O O<Space><BS><ESC> | |
" Yank to end line. | |
nnoremap [Alt]y y$ | |
nnoremap Y y$ | |
nnoremap x "_x | |
" Useless commands | |
nnoremap [Alt]; ; | |
nnoremap [Alt], , | |
"}}} | |
" q: Quickfix "{{{ | |
" The prefix key. | |
nnoremap [Quickfix] <Nop> | |
nmap F [Quickfix] | |
" Disable Ex-mode. | |
nnoremap Q q | |
" Toggle quickfix window. | |
nnoremap <silent> [Quickfix]<Space> | |
\ :<C-u>call <SID>toggle_quickfix_window()<CR> | |
function! s:toggle_quickfix_window() | |
let _ = winnr('$') | |
cclose | |
if _ == winnr('$') | |
copen | |
setlocal nowrap | |
setlocal whichwrap=b,s | |
endif | |
endfunction | |
"}}} | |
" Jump mark can restore column."{{{ | |
nnoremap \ ` | |
" Useless command. | |
nnoremap M m | |
"}}} | |
" Smart <C-f>, <C-b>. | |
nnoremap <silent> <C-f> <C-f> | |
nnoremap <silent> <C-b> <C-b> | |
" Disable ZZ. | |
nnoremap ZZ <Nop> | |
" Like gv, but select the last changed text. | |
" nnoremap gc `[v`] | |
" Specify the last changed text as {motion}. | |
" vnoremap <silent> gc :<C-u>normal gc<CR> | |
" onoremap <silent> gc :<C-u>normal gc<CR> | |
" Auto escape / and ? in search command. | |
cnoremap <expr> / getcmdtype() == '/' ? '\/' : '/' | |
" Smart }."{{{ | |
nnoremap <silent> } :<C-u>call ForwardParagraph()<CR> | |
onoremap <silent> } :<C-u>call ForwardParagraph()<CR> | |
xnoremap <silent> } <Esc>:<C-u>call ForwardParagraph()<CR>mzgv`z | |
function! ForwardParagraph() | |
let cnt = v:count ? v:count : 1 | |
let i = 0 | |
while i < cnt | |
if !search('^\s*\n.*\S','W') | |
normal! G$ | |
return | |
endif | |
let i = i + 1 | |
endwhile | |
endfunction | |
"}}} | |
" Smart home and smart end."{{{ | |
nnoremap <silent> gh :<C-u>call SmartHome('n')<CR> | |
nnoremap <silent> gl :<C-u>call SmartEnd('n')<CR> | |
xnoremap <silent> gh <ESC>:<C-u>call SmartHome('v')<CR> | |
xnoremap <silent> gl <ESC>:<C-u>call SmartEnd('v')<CR> | |
" Smart home function"{{{ | |
function! 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 "" | |
endfunction"}}} | |
" Smart end function"{{{ | |
function! 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 "" | |
endfunction "}}} | |
"}}} | |
" Jump to a line and the line of before and after of the same indent."{{{ | |
" Useful for Python. | |
nnoremap <silent> g{ :<C-u>call search('^' . | |
\ matchstr(getline(line('.') + 1), '\(\s*\)') .'\S', 'b')<CR>^ | |
nnoremap <silent> g} :<C-u>call search('^' . | |
\ matchstr(getline(line('.')), '\(\s*\)') .'\S')<CR>^ | |
"}}} | |
" Select rectangle. | |
xnoremap r <C-v> | |
" Select until end of current line in visual mode. | |
xnoremap v $h | |
" Paste next line. | |
nnoremap <silent> gp o<ESC>p^ | |
nnoremap <silent> gP O<ESC>P^ | |
xnoremap <silent> gp o<ESC>p^ | |
xnoremap <silent> gP O<ESC>P^ | |
" Redraw. | |
" nnoremap <silent> <C-l> :<C-u>redraw!<CR> | |
" Folding."{{{ | |
" If press h on head, fold close. | |
"nnoremap <expr> h col('.') == 1 && foldlevel(line('.')) > 0 ? 'zc' : 'h' | |
" If press l on fold, fold open. | |
nnoremap <expr> l foldclosed(line('.')) != -1 ? 'zo0' : 'l' | |
" If press h on head, range fold close. | |
"xnoremap <expr> h col('.') == 1 && foldlevel(line('.')) > 0 ? 'zcgv' : 'h' | |
" If press l on fold, range fold open. | |
xnoremap <expr> l foldclosed(line('.')) != -1 ? 'zogv0' : 'l' | |
noremap [Space]j zj | |
noremap [Space]k zk | |
noremap [Space]h zc | |
noremap [Space]l zo | |
noremap [Space]a za | |
noremap [Space]m zM | |
noremap [Space]i zMzv | |
noremap [Space]rr zR | |
noremap [Space]f zf | |
noremap [Space]d zd | |
noremap [Space]u :<C-u>Unite outline:foldings<CR> | |
noremap [Space]gg :<C-u>echo FoldCCnavi()<CR> | |
"}}} | |
" Substitute. | |
xnoremap s :s//g<Left><Left> | |
"}}} | |
" Easy escape."{{{ | |
inoremap jj <ESC> | |
" inoremap <expr> j getline('.')[col('.') - 2] ==# 'j' ? "\<BS>\<ESC>" : 'j' | |
cnoremap <expr> j getcmdline()[getcmdpos()-2] ==# 'j' ? "\<BS>\<C-c>" : 'j' | |
onoremap jj <ESC> | |
" inoremap j<Space> j | |
onoremap j<Space> j | |
"}}} | |
" Execute countable 'n.'. | |
" EXAMPLE: 3@n | |
let @n='n.' | |
" a>, i], etc... "{{{ | |
" <angle> | |
onoremap aa a> | |
xnoremap aa a> | |
onoremap ia i> | |
xnoremap ia i> | |
" [rectangle] | |
onoremap ar a] | |
xnoremap ar a] | |
onoremap ir i] | |
xnoremap ir i] | |
" 'quote' | |
onoremap aq a' | |
xnoremap aq a' | |
onoremap iq i' | |
xnoremap iq i' | |
" "double quote" | |
onoremap ad a" | |
xnoremap ad a" | |
onoremap id i" | |
xnoremap id i" | |
"}}} | |
" Move to top/center/bottom. | |
noremap <expr> zz (winline() == (winheight(0)+1)/ 2) ? | |
\ 'zt' : (winline() == 1)? 'zb' : 'zz' | |
" Capitalize. | |
nnoremap gu gUiw`] | |
inoremap <C-q> <ESC>gUiw`]a | |
" Clear highlight. | |
nnoremap <ESC><ESC> :nohlsearch<CR> | |
" operator-html-escape.vim | |
nmap <Leader>h <Plug>(operator-html-escape) | |
xmap <Leader>h <Plug>(operator-html-escape) | |
" Easily macro. | |
nnoremap @@ @a | |
"}}} | |
" Improved increment. | |
nmap <C-a> <SID>(increment) | |
nmap <C-x> <SID>(decrement) | |
nnoremap <silent> <SID>(increment) :AddNumbers 1<CR> | |
nnoremap <silent> <SID>(decrement) :AddNumbers -1<CR> | |
command! -range -nargs=1 AddNumbers | |
\ call s:add_numbers((<line2>-<line1>+1) * eval(<args>)) | |
function! s:add_numbers(num) | |
let prev_line = getline('.')[: col('.')-1] | |
let next_line = getline('.')[col('.') :] | |
let prev_num = matchstr(prev_line, '\d\+$') | |
if prev_num != '' | |
let next_num = matchstr(next_line, '^\d\+') | |
let new_line = prev_line[: -len(prev_num)-1] . | |
\ printf('%0'.len(prev_num . next_num).'d', | |
\ max([0, prev_num . next_num + a:num])) . next_line[len(next_num):] | |
else | |
let new_line = prev_line . substitute(next_line, '\d\+', | |
\ "\\=printf('%0'.len(submatch(0)).'d', | |
\ max([0, submatch(0) + a:num]))", '') | |
endif | |
if getline('.') !=# new_line | |
call setline('.', new_line) | |
endif | |
endfunction | |
" Syntax check. | |
nnoremap <silent> [Window]y | |
\ :<C-u>echo map(synstack(line('.'), col('.')), | |
\ 'synIDattr(v:val, "name")')<CR> | |
" Open github URI. | |
call operator#user#define('open-neobundlepath', 'OpenNeoBundlePath') | |
nmap gz <Plug>(operator-open-neobundlepath) | |
xmap gz <Plug>(operator-open-neobundlepath) | |
function! OpenNeoBundlePath(motion_wise) "{{{ | |
if line("'[") != line("']") | |
return | |
endif | |
let start = col("'[") - 1 | |
let end = col("']") | |
let sel = strpart(getline('.'), start, end - start) | |
let sel = substitute(sel, | |
\'^\%(github\|gh\|git@github\.com\):\(.\+\)', | |
\ 'https://github.com/\1', '') | |
let sel = substitute(sel, | |
\'^\%(bitbucket\|bb\):\(.\+\)', 'https://bitbucket.org/\1', '') | |
let sel = substitute(sel, | |
\'^gist:\(.\+\)', 'https://gist.github.com/\1', '') | |
let sel = substitute(sel, | |
\'^git://', 'https://', '') | |
if sel =~ '^https\?://' | |
call openbrowser#open(sel) | |
elseif sel =~ '/' | |
call openbrowser#open('https://github.com/'.sel) | |
else | |
call openbrowser#open('https://github.com/vim-scripts/'.sel) | |
endif | |
endfunction "}}} | |
"}}} | |
"--------------------------------------------------------------------------- | |
" Commands:"{{{ | |
" | |
" Toggle options. "{{{ | |
function! ToggleOption(option_name) | |
execute 'setlocal' a:option_name.'!' | |
execute 'setlocal' a:option_name.'?' | |
endfunction "}}} | |
" Toggle variables. "{{{ | |
function! ToggleVariable(variable_name) | |
if eval(a:variable_name) | |
execute 'let' a:variable_name.' = 0' | |
else | |
execute 'let' a:variable_name.' = 1' | |
endif | |
echo printf('%s = %s', a:variable_name, eval(a:variable_name)) | |
endfunction "}}} | |
" Display diff with the file. | |
command! -nargs=1 -complete=file Diff vertical diffsplit <args> | |
" Display diff from last save. | |
command! DiffOrig vert new | setlocal bt=nofile | r # | 0d_ | diffthis | wincmd p | diffthis | |
" Disable diff mode. | |
command! -nargs=0 Undiff setlocal nodiff noscrollbind wrap | |
" :HighlightWith {filetype} ['a 'b] XXX: Don't work in some case."{{{ | |
command! -nargs=+ -range=% HighlightWith <line1>,<line2>call s:highlight_with(<q-args>) | |
" xnoremap [Space]h q:HighlightWith<Space> | |
function! s:highlight_with(args) range | |
if a:firstline == 1 && a:lastline == line('$') | |
return | |
endif | |
let c = get(b:, 'highlight_count', 0) | |
let ft = matchstr(a:args, '^\w\+') | |
if globpath(&rtp, 'syntax/' . ft . '.vim') == '' | |
return | |
endif | |
unlet! b:current_syntax | |
let save_isk= &l:isk " For scheme. | |
execute printf('syntax include @highlightWith%d syntax/%s.vim', | |
\ c, ft) | |
let &l:isk= save_isk | |
execute printf('syntax region highlightWith%d start=/\%%%dl/ end=/\%%%dl$/ ' | |
\ . 'contains=@highlightWith%d', | |
\ c, a:firstline, a:lastline, c) | |
let b:highlight_count = c + 1 | |
endfunction"}}} | |
"}}} | |
"--------------------------------------------------------------------------- | |
" Functions:"{{{ | |
" | |
function! s:strchars(str) | |
return len(substitute(a:str, '.', 'x', 'g')) | |
endfunction | |
function! s:strwidthpart(str, width) | |
if a:width <= 0 | |
return '' | |
endif | |
let ret = a:str | |
let width = s:wcswidth(a:str) | |
while width > a:width | |
let char = matchstr(ret, '.$') | |
let ret = ret[: -1 - len(char)] | |
let width -= s:wcswidth(char) | |
endwhile | |
return ret | |
endfunction | |
function! s:strwidthpart_reverse(str, width) | |
if a:width <= 0 | |
return '' | |
endif | |
let ret = a:str | |
let width = s:wcswidth(a:str) | |
while width > a:width | |
let char = matchstr(ret, '^.') | |
let ret = ret[len(char) :] | |
let width -= s:wcswidth(char) | |
endwhile | |
return ret | |
endfunction | |
if v:version >= 703 | |
" Use builtin function. | |
function! s:wcswidth(str) | |
return strwidth(a:str) | |
endfunction | |
else | |
function! s:wcswidth(str) | |
if a:str =~# '^[\x00-\x7f]*$' | |
return strlen(a:str) | |
end | |
let mx_first = '^\(.\)' | |
let str = a:str | |
let width = 0 | |
while 1 | |
let ucs = char2nr(substitute(str, mx_first, '\1', '')) | |
if ucs == 0 | |
break | |
endif | |
let width += s:_wcwidth(ucs) | |
let str = substitute(str, mx_first, '', '') | |
endwhile | |
return width | |
endfunction | |
" UTF-8 only. | |
function! s:_wcwidth(ucs) | |
let ucs = a:ucs | |
if (ucs >= 0x1100 | |
\ && (ucs <= 0x115f | |
\ || ucs == 0x2329 | |
\ || ucs == 0x232a | |
\ || (ucs >= 0x2e80 && ucs <= 0xa4cf | |
\ && ucs != 0x303f) | |
\ || (ucs >= 0xac00 && ucs <= 0xd7a3) | |
\ || (ucs >= 0xf900 && ucs <= 0xfaff) | |
\ || (ucs >= 0xfe30 && ucs <= 0xfe6f) | |
\ || (ucs >= 0xff00 && ucs <= 0xff60) | |
\ || (ucs >= 0xffe0 && ucs <= 0xffe6) | |
\ || (ucs >= 0x20000 && ucs <= 0x2fffd) | |
\ || (ucs >= 0x30000 && ucs <= 0x3fffd) | |
\ )) | |
return 2 | |
endif | |
return 1 | |
endfunction | |
endif | |
"}}} | |
"--------------------------------------------------------------------------- | |
" Platform depends:"{{{ | |
" | |
if s:is_windows | |
" For Windows"{{{ | |
" In Windows, can't find exe, when $PATH isn't contained $VIM. | |
if $PATH !~? '\(^\|;\)' . escape($VIM, '\\') . '\(;\|$\)' | |
let $PATH = $VIM . ';' . $PATH | |
endif | |
" Shell settings. | |
" Use NYAOS. | |
"set shell=nyaos.exe | |
"set shellcmdflag=-e | |
"set shellpipe=\|&\ tee | |
"set shellredir=>%s\ 2>&1 | |
"set shellxquote=\" | |
" Use bash. | |
"set shell=bash.exe | |
"set shellcmdflag=-c | |
"set shellpipe=2>&1\|\ tee | |
"set shellredir=>%s\ 2>&1 | |
"set shellxquote=\" | |
" Change colorscheme. | |
" Don't override colorscheme. | |
if !exists('g:colors_name') && !has('gui_running') | |
colorscheme molokai | |
endif | |
" Popup color. | |
hi Pmenu ctermbg=8 | |
hi PmenuSel ctermbg=1 | |
hi PmenuSbar ctermbg=0 | |
"}}} | |
else | |
" For Linux"{{{ | |
if exists('$WINDIR') || !executable('zsh') | |
" Cygwin. | |
" Use bash. | |
set shell=bash | |
else | |
" Use zsh. | |
set shell=zsh | |
endif | |
" Set path. | |
let $PATH = expand('~/bin').':/usr/local/bin/:'.$PATH | |
" For non GVim. | |
if !has('gui_running') | |
" Enable 256 color terminal. | |
if !exists('$TMUX') | |
set t_Co=256 | |
" For screen."{{{ | |
if &term =~ '^screen' | |
augroup MyAutoCmd | |
" Show filename on screen statusline. | |
" But invalid 'another' screen buffer. | |
autocmd BufEnter * if $WINDOW != 0 && | |
\ bufname('') !~ '[[:alnum:]]*://' | |
\ | silent! exe '!echo -n "\ekv:%:t\e\\"' | endif | |
" When 'mouse' isn't empty, Vim will freeze. Why? | |
autocmd VimLeave * :set mouse= | |
augroup END | |
endif | |
" For prevent bug. | |
autocmd MyAutoCmd VimLeave * set term=screen | |
"}}} | |
set ttymouse=sgr | |
endif | |
if has('gui') | |
colorscheme molokai | |
endif | |
" Change cursor shape. | |
if &term =~ "xterm" | |
let &t_SI = "\<Esc>]12;lightgreen\x7" | |
let &t_EI = "\<Esc>]12;white\x7" | |
endif | |
endif | |
"}}} | |
endif | |
" Using the mouse on a terminal. | |
" if has('mouse') | |
" set mouse=a | |
" if has('mouse_sgr') | |
" set ttymouse=sgr | |
" elseif v:version > 703 || v:version is 703 && has('patch632') | |
" " I couldn't use has('mouse_sgr') :-( | |
" set ttymouse=sgr | |
" else | |
" set ttymouse=xterm2 | |
" endif | |
" endif | |
"}}} | |
"--------------------------------------------------------------------------- | |
" Others:"{{{ | |
" | |
" Enable mouse support. | |
set mouse=a | |
" Default home directory. | |
let t:cwd = getcwd() | |
"}}} | |
call neobundle#call_hook('on_source') | |
if !has('vim_starting') | |
if exists(':IndentLinesReset') | |
IndentLinesReset | |
endif | |
endif | |
set secure |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment