.vimrc.fork
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Ack searching and cope displaying
" requires ack.vim - it's much better than vimgrep/grep
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" When you press gv you Ack after the selected text
vnoremap <silent> gv :call VisualSelection('gv', '')<CR>
" Open Ack and put the cursor in the right position
"map <leader>g :Ack
noremap <Leader>a :Ag<SPACE><C-R>=expand("<cword>")<CR><SPACE>--
noremap <Leader>ff :Ack<SPACE><C-R>=expand("<cword>")<CR><SPACE>%<CR>
noremap <Leader>fr :Rooter<CR>:Ag<SPACE><C-R>=expand("<cword>")<CR><SPACE>--
noremap <Leader>so :so ~/.vimrc<CR>
" When you press <leader>r you can search and replace the selected text
vnoremap <silent> <leader>r :call VisualSelection('replace', '')<CR>
" Do :help cope if you are unsure what cope is. It's super useful!
"
" When you search with Ack, display your results in cope by doing:
" <leader>cc
"
" To go to the next search result do:
" <leader>n
"
" To go to the previous search results do:
" <leader>p
"
map <leader>ce :botright cope<cr>
map <leader>ccl :cclose<cr>
map <leader>co ggVGy:tabnew<cr>:set syntax=qf<cr>pgg
map <F6> :cn<cr>
map <F7> :cp<cr>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Misc
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Remove the Windows ^M - when the encodings gets messed up
noremap <F8> mmHmt:%s/<C-V><cr>//ge<cr>'tzt'm
""""""""""""""""""""""""""""""
" => Visual mode related
""""""""""""""""""""""""""""""
" Visual mode pressing * or # searches for the current selection
" Super useful! From an idea by Michael Naumann
vnoremap <silent> * :call VisualSelection('f', '')<CR>
vnoremap <silent> # :call VisualSelection('b', '')<CR>
function! CmdLine(str)
exe "menu Foo.Bar :" . a:str
emenu Foo.Bar
unmenu Foo
endfunction
function! VisualSelection(direction, extra_filter) range
let l:saved_reg = @"
execute "normal! vgvy"
let l:pattern = escape(@", '\\/.*$^~[]')
let l:pattern = substitute(l:pattern, "\n$", "", "")
if a:direction == 'b'
execute "normal ?" . l:pattern . "^M"
elseif a:direction == 'gv'
call CmdLine("Ack \"" . l:pattern . "\" " )
elseif a:direction == 'replace'
call CmdLine("%s" . '/'. l:pattern . '/')
elseif a:direction == 'f'
execute "normal /" . l:pattern . "^M"
endif
let @/ = l:pattern
let @" = l:saved_reg
endfunctio range
"Use arrow key to change buffer"
noremap <left> :bp<CR>
noremap <right> :bn<CR>
map <leader>tn :tabnew<cr>
map <leader>to :tabonly<cr>
map <leader>tc :tabclose<cr>
map <leader>tm :tabmove
" 命令行模式增强,ctrl - a到行首, -e 到行尾
cnoremap <C-j> <t_kd>
cnoremap <C-k> <t_ku>
cnoremap <C-a> <Home>
cnoremap <C-e> <End>
set pastetoggle=<F4> " when in insert mode, press <F5> to go to
" paste mode, where you can paste mass data
" that won't be autoindented
" disbale paste mode when leaving insert mode
au InsertLeave * set nopaste
" 定义函数AutoSetFileHead,自动插入文件头
autocmd BufNewFile *.sh,*.py exec ":call AutoSetFileHead()"
function! AutoSetFileHead()
"如果文件类型为.sh文件
if &filetype == 'sh'
call setline(1, "\#!/bin/bash")
endif
"如果文件类型为python
if &filetype == 'python'
call setline(1, "\#!/usr/bin/env python")
call append(1, "\# encoding: utf-8")
endif
normal G
normal o
normal o
endfunc
nnoremap <Leader>w :w !sudo tee >/dev/null %<CR>
" jj 替换 Esc
inoremap jj <Esc>
" Don't close window, when deleting a buffer
command! Bclose call <SID>BufcloseCloseIt()
function! <SID>BufcloseCloseIt()
let l:currentBufNum = bufnr("%")
let l:alternateBufNum = bufnr("#")
if buflisted(l:alternateBufNum)
buffer #
else
bnext
endif
if bufnr("%") == l:currentBufNum
new
endif
if buflisted(l:currentBufNum)
execute("bdelete! ".l:currentBufNum)
endif
endfunction
" Move a line of text using ALT+[jk] or Comamnd+[jk] on mac
"nmap <M-j> mz:m+<cr>`z
"nmap <M-k> mz:m-2<cr>`z
"vmap <M-j> :m'>+<cr>`<my`>mzgv`yo`z
"vmap <M-k> :m'<-2<cr>`>my`<mzgv`yo`z
" Specify the behavior when switching between buffers
try
set switchbuf=useopen,usetab,newtab
set stal=2
catch
endtry
" YankRing stuff
"let g:yankring_history_dir = '$HOME/.vim/.tmp'
nnoremap <F2> :YRShow<CR>
"gitsession
nnoremap <leader>gss :GitSessionSave<cr><cr>
nnoremap <leader>gsl :GitSessionLoad<cr>
nnoremap <leader>gsd :GitSessionDelete<cr>
"vimrooter
let g:rooter_manual_only = 1
let g:rooter_use_lcd = 1
"map <silent> <unique> <Leader>foo <Plug>RooterChangeToRootDirectory
"vim-grep"
nnoremap <Leader>fgg :Rooter<CR>:Grep<SPACE><C-R>=expand("<cword>")<CR><CR>
nnoremap <Leader>fgl :Grep<SPACE><C-R>=expand("<cword>")<CR><CR>
set fo-=ro
"use fuggitive Ggrep
"nnoremap <Leader>fgg :Rooter<CR>:Ggrep<SPACE>-w<Space><C-R>=expand("<cword>")<CR><CR>
"nnoremap <Leader>fgl :Ggrep<SPACE>-w<Space><C-R>=expand("<cword>")<CR><space>.<CR>
"vim-jumpthere"
"nnoremap <Leader>jp :TabJump<SPACE>
set autoread
nmap <Leader>s :tabedit $HOME/.vimrc<CR>
highlight clear SpecialKey
"ctrlp-z"
let g:ctrlp_z_nerdtree = 1
let g:ctrlp_extensions = ['Z', 'F']
nnoremap <Leader>pz :CtrlPZ<Cr>
nnoremap <Leader>pf :CtrlPF<Cr>
"move"
vmap <SPACE>j <Plug>MoveBlockDown
vmap <SPACE>k <Plug>MoveBlockUp
nmap <SPACE>j <Plug>MoveLineDown
nmap <SPACE>k <Plug>MoveLineUp
"tmuxnavigate"
let g:tmux_navigator_no_mappings = 1
nnoremap <silent> <C-H> :TmuxNavigateLeft<cr>
nnoremap <silent> <C-J> :TmuxNavigateDown<cr>
nnoremap <silent> <C-K> :TmuxNavigateUp<cr>
nnoremap <silent> <C-L> :TmuxNavigateRight<cr>
nnoremap <silent> <C-\> :TmuxNavigatePrevious<cr>
nnoremap <silent> <Leader>pcf :Rooter<CR>:FZF -m<CR>
nnoremap <silent> <Leader>pce :Rooter<CR>:FZF -m -e<CR>
let g:EclimCompletionMethod = 'omnifunc'
if !exists('g:neocomplete#force_omni_input_patterns')
let g:neocomplete#force_omni_input_patterns = {}
endif
let g:neocomplete#force_omni_input_patterns.java = '\k\.\k*'
"let g:ackprg = 'ag --nogroup --nocolor --column --smart-case -w'
"
function! Logcheck()
let s:file = expand('%:p')
let s:pattern = 'Exception|Shutting down VM|fatal|FATAL|error|Error|system.err|System.err|died'
execute "Ack \"" . s:pattern . "\" " . s:file
endfunction
nnoremap <silent> <Leader>lc :call Logcheck()<CR>
.vimrc.bundles
" Modeline and Notes {
" vim: set sw=4 ts=4 sts=4 et tw=78 foldmarker={,} foldlevel=0 foldmethod=marker spell:
"
" __ _ _____ _
" ___ _ __ / _/ |___ / __ __(_)_ __ ___
" / __| '_ \| |_| | |_ \ _____\ \ / /| | '_ ` _ \
" \__ \ |_) | _| |___) |_____|\ V / | | | | | | |
" |___/ .__/|_| |_|____/ \_/ |_|_| |_| |_|
" |_|
"
" This is the personal .vimrc.bundles file of Steve Francia.
" While much of it is beneficial for general use, I would
" recommend picking out the parts you want and understand.
"
" This file imports the various plugins of spf13. If you
" wish to alter which groups are imported, see vimrc.before.
" If you wish to add or remove individual bundles, create
" ~/.vimrc.bundles.local and `Bundle` or `UnBundle` as needed
" from there.
"
" You can find me at http://spf13.com
" }
" Environment {
" Basics {
set nocompatible " Must be first line
set background=dark " Assume a dark background
" }
" Windows Compatible {
" On Windows, also use '.vim' instead of 'vimfiles'; this makes synchronization
" across (heterogeneous) systems easier.
if has('win32') || has('win64')
set runtimepath=$HOME/.vim,$VIM/vimfiles,$VIMRUNTIME,$VIM/vimfiles/after,$HOME/.vim/after
" Be nice and check for multi_byte even if the config requires
" multi_byte support most of the time
if has("multi_byte")
" Windows cmd.exe still uses cp850. If Windows ever moved to
" Powershell as the primary terminal, this would be utf-8
set termencoding=cp850
" Let Vim use utf-8 internally, because many scripts require this
set encoding=utf-8
setglobal fileencoding=utf-8
" Windows has traditionally used cp1252, so it's probably wise to
" fallback into cp1252 instead of eg. iso-8859-15.
" Newer Windows files might contain utf-8 or utf-16 LE so we might
" want to try them first.
set fileencodings=ucs-bom,utf-8,utf-16le,cp1252,iso-8859-15
endif
endif
" }
" Setup Bundle Support {
" The next three lines ensure that the ~/.vim/bundle/ system works
filetype off
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" }
" Add an UnBundle command {
function! UnBundle(arg, ...)
let bundle = vundle#config#init_bundle(a:arg, a:000)
call filter(g:bundles, 'v:val["name_spec"] != "' . a:arg . '"')
endfunction
com! -nargs=+ UnBundle
\ call UnBundle(<args>)
" }
" }
" Bundles {
" Deps {
Plugin 'gmarik/Vundle.vim'
Plugin 'MarcWeber/vim-addon-mw-utils'
Plugin 'tomtom/tlib_vim'
Plugin 'mileszs/ack.vim'
let g:ackprg="ack -H --nocolor --nogroup --column"
" }
" In your .vimrc.before.local file
" list only the plugin groups you will use
if !exists('g:spf13_bundle_groups')
"let g:spf13_bundle_groups=['general', 'writing', 'neocomplcache', 'programming', 'php', 'ruby', 'python', 'twig', 'javascript', 'html', 'misc',]
let g:spf13_bundle_groups=['general', 'neocomplete', 'programming',]
endif
" To override all the included bundles, add the following to your
" .vimrc.bundles.local file:
" let g:override_spf13_bundles = 1
if !exists("g:override_spf13_bundles")
" General {
if count(g:spf13_bundle_groups, 'general')
Plugin 'scrooloose/nerdtree'
Plugin 'altercation/vim-colors-solarized'
Plugin 'spf13/vim-colors'
"Plugin 'tpope/vim-surround'
Plugin 'spf13/vim-autoclose'
Plugin 'kien/ctrlp.vim'
Plugin 'terryma/vim-multiple-cursors'
"Plugin 'vim-scripts/sessionman.vim'
"Plugin 'matchit.zip'
if (has("python") || has("python3")) && exists('g:spf13_use_powerline') && !exists('g:spf13_use_old_powerline')
Plugin 'Lokaltog/powerline', {'rtp':'/powerline/bindings/vim'}
elseif exists('g:spf13_use_powerline') && exists('g:spf13_use_old_powerline')
Plugin 'Lokaltog/vim-powerline'
else
Plugin 'bling/vim-airline'
endif
"Plugin 'bling/vim-bufferline'
Plugin 'Lokaltog/vim-easymotion'
Plugin 'godlygeek/csapprox'
Plugin 'jistr/vim-nerdtree-tabs'
Plugin 'flazz/vim-colorschemes'
Plugin 'mbbill/undotree'
"Plugin 'nathanaelkane/vim-indent-guides'
if !exists('g:spf13_no_views')
"Plugin 'vim-scripts/restore_view.vim'
endif
Plugin 'mhinz/vim-signify'
"Plugin 'tpope/vim-abolish.git'
"Plugin 'osyo-manga/vim-over'
Plugin 'justinmk/vim-sneak'
"Plugin 'kana/vim-textobj-user'
"Plugin 'kana/vim-textobj-indent'
endif
" }
" Writing {
if count(g:spf13_bundle_groups, 'writing')
Plugin 'reedes/vim-litecorrect'
Plugin 'reedes/vim-textobj-sentence'
Plugin 'reedes/vim-textobj-quote'
Plugin 'reedes/vim-wordy'
endif
" }
" General Programming {
if count(g:spf13_bundle_groups, 'programming')
" Pick one of the checksyntax, jslint, or syntastic
Plugin 'scrooloose/syntastic'
Plugin 'tpope/vim-fugitive'
"Plugin 'mattn/webapi-vim'
"Plugin 'mattn/gist-vim'
Plugin 'scrooloose/nerdcommenter'
"Plugin 'godlygeek/tabular'
if executable('ctags')
Plugin 'majutsushi/tagbar'
endif
endif
" }
" Snippets & AutoComplete {
if count(g:spf13_bundle_groups, 'snipmate')
Plugin 'garbas/vim-snipmate'
Plugin 'honza/vim-snippets'
" Source support_function.vim to support vim-snippets.
if filereadable(expand("~/.vim/bundle/vim-snippets/snippets/support_functions.vim"))
source ~/.vim/bundle/vim-snippets/snippets/support_functions.vim
endif
elseif count(g:spf13_bundle_groups, 'youcompleteme')
Plugin 'Valloric/YouCompleteMe'
Plugin 'SirVer/ultisnips'
Plugin 'honza/vim-snippets'
elseif count(g:spf13_bundle_groups, 'neocomplcache')
Plugin 'Shougo/neocomplcache'
Plugin 'Shougo/neosnippet'
Plugin 'Shougo/neosnippet-snippets'
Plugin 'honza/vim-snippets'
elseif count(g:spf13_bundle_groups, 'neocomplete')
Plugin 'Shougo/neocomplete.vim.git'
Plugin 'Shougo/neosnippet'
Plugin 'Shougo/neosnippet-snippets'
Plugin 'honza/vim-snippets'
endif
" }
" PHP {
if count(g:spf13_bundle_groups, 'php')
Plugin 'spf13/PIV'
Plugin 'arnaud-lb/vim-php-namespace'
endif
" }
" Python {
if count(g:spf13_bundle_groups, 'python')
" Pick either python-mode or pyflakes & pydoc
Plugin 'klen/python-mode'
Plugin 'python.vim'
Plugin 'python_match.vim'
Plugin 'pythoncomplete'
endif
" }
" Javascript {
if count(g:spf13_bundle_groups, 'javascript')
Plugin 'elzr/vim-json'
Plugin 'groenewege/vim-less'
Plugin 'pangloss/vim-javascript'
Plugin 'briancollins/vim-jst'
Plugin 'kchmck/vim-coffee-script'
endif
" }
" Scala {
if count(g:spf13_bundle_groups, 'scala')
Plugin 'derekwyatt/vim-scala'
Plugin 'derekwyatt/vim-sbt'
endif
" }
" Haskell {
if count(g:spf13_bundle_groups, 'haskell')
Plugin 'travitch/hasksyn'
Plugin 'dag/vim2hs'
Plugin 'Twinside/vim-haskellConceal'
Plugin 'Twinside/vim-haskellFold'
Plugin 'lukerandall/haskellmode-vim'
Plugin 'eagletmt/neco-ghc'
Plugin 'eagletmt/ghcmod-vim'
Plugin 'Shougo/vimproc'
Plugin 'adinapoli/cumino'
Plugin 'bitc/vim-hdevtools'
endif
" }
" HTML {
if count(g:spf13_bundle_groups, 'html')
Plugin 'amirh/HTML-AutoCloseTag'
Plugin 'hail2u/vim-css3-syntax'
Plugin 'gorodinskiy/vim-coloresque'
Plugin 'tpope/vim-haml'
endif
" }
" Ruby {
if count(g:spf13_bundle_groups, 'ruby')
Plugin 'tpope/vim-rails'
let g:rubycomplete_buffer_loading = 1
"let g:rubycomplete_classes_in_global = 1
"let g:rubycomplete_rails = 1
endif
" }
" Go Lang {
if count(g:spf13_bundle_groups, 'go')
"Plugin 'Blackrush/vim-gocode'
Plugin 'fatih/vim-go'
endif
" }
" Misc {
if count(g:spf13_bundle_groups, 'misc')
Plugin 'tpope/vim-markdown'
Plugin 'spf13/vim-preview'
Plugin 'tpope/vim-cucumber'
Plugin 'quentindecock/vim-cucumber-align-pipes'
Plugin 'Puppet-Syntax-Highlighting'
endif
" }
" Twig {
if count(g:spf13_bundle_groups, 'twig')
Plugin 'beyondwords/vim-twig'
endif
" }
endif
" }
" Use fork bundles config if available {
if filereadable(expand("~/.vimrc.bundles.fork"))
source ~/.vimrc.bundles.fork
endif
" }
" Use local bundles config if available {
if filereadable(expand("~/.vimrc.bundles.local"))
source ~/.vimrc.bundles.local
endif
" }
call vundle#end() " required
.vimrc.bundles.local
Plugin 'cmdline-completion'
Plugin 'kshenoy/vim-signature'
Plugin 'terryma/vim-expand-region'
Plugin 'tpope/vim-repeat'
Plugin 'jeetsukumaran/vim-buffergator'
"Plugin 'rgarver/Kwbd.vim'
Plugin 'gregsexton/gitv'
Plugin 'YankRing.vim'
Plugin 'tacahiroy/ctrlp-funky'
Plugin 'JazzCore/ctrlp-cmatcher'
"Plugin 'wting/gitsessions.vim'
Plugin 'airblade/vim-rooter'
Plugin 'teoljungberg/vim-grep'
"Plugin 'mkropat/vim-jumpthere'
Plugin 'Yggdroot/indentLine'
Plugin 'vim-scripts/ctrlp-z'
Plugin 'matze/vim-move'
Plugin 'christoomey/vim-tmux-navigator'
Plugin 'wellle/targets.vim'
Plugin 'justinmk/vim-gtfo'
Plugin 'dhruvasagar/vim-vinegar'
Plugin 'junegunn/fzf'
Plugin 'ervandew/ag'
Plugin 'airblade/vim-gitgutter'
Plugin 'eclim'
Plugin 'junegunn/vim-pseudocl'
Plugin 'junegunn/vim-oblique'
Plugin 'tpope/vim-unimpaired'
"Plugin 'charz/multi-cscope-db'
.vimrc.before
" Modeline and Notes {
" vim: set sw=4 ts=4 sts=4 et tw=78 foldmarker={,} foldlevel=0 foldmethod=marker:
"
" __ _ _____ _
" ___ _ __ / _/ |___ / __ __(_)_ __ ___
" / __| '_ \| |_| | |_ \ _____\ \ / /| | '_ ` _ \
" \__ \ |_) | _| |___) |_____|\ V / | | | | | | |
" |___/ .__/|_| |_|____/ \_/ |_|_| |_| |_|
" |_|
"
" This is the personal .vimrc.before file of Steve Francia.
" While much of it is beneficial for general use, I would
" recommend picking out the parts you want and understand.
"
" This file is for options which must be set *before* plugins
" are loaded and the main .vimrc config is run. Most of these
" are for preventing mappings or commands from being created.
"
" You can find me at http://spf13.com
" }
" spf13 options {
" Prevent automatically changing to open file directory
" let g:spf13_no_autochdir = 1
" Disable views
" let g:spf13_no_views = 1
" Leader keys
" let g:spf13_leader='\'
" let g:spf13_localleader='_'
" Disable easier moving in tabs and windows
" let g:spf13_no_easyWindows = 1
" Disable wrap relative motion for start/end line motions
" let g:spf13_no_wrapRelMotion = 1
" Disable fast tab navigation
" let g:spf13_no_fastTabs = 1
" Clear search highlighting
" let g:spf13_clear_search_highlight = 1
" Disable neosnippet expansion
" This maps over <C-k> and does some Supertab
" emulation with snippets
" let g:spf13_no_neosnippet_expand = 1
" Disable whitespace stripping
" let g:spf13_keep_trailing_whitespace = 1
" Enable powerline symbols
" let g:airline_powerline_fonts = 1
" vim files directory
" let g:spf13_consolidated_directory = <full path to desired directory>
" eg: let g:spf13_consolidated_directory = $HOME . '/.vim/'
" This makes the completion popup strictly passive.
" Keypresses acts normally. <ESC> takes you of insert mode, words don't
" automatically complete, pressing <CR> inserts a newline, etc. Iff the
" menu is open, tab will cycle through it. If a snippet is selected, <C-k>
" expands it and jumps between fields.
" let g:spf13_noninvasive_completion = 1
" Don't turn conceallevel or concealcursor
" let g:spf13_no_conceal = 1
" For some colorschemes, autocolor will not work (eg: 'desert', 'ir_black')
" Indent guides will attempt to set your colors smartly. If you
" want to control them yourself, do it here.
" let g:indent_guides_auto_colors = 0
" autocmd VimEnter,Colorscheme * :hi IndentGuidesOdd guibg=#212121 ctermbg=233
" autocmd VimEnter,Colorscheme * :hi IndentGuidesEven guibg=#404040 ctermbg=234
" Leave the default font and size in GVim
" To set your own font, do it from ~/.vimrc.local
let g:spf13_no_big_font = 1
" Disable omni complete
" let g:spf13_no_omni_complete = 1
" Don't create default mappings for multicursors
" See :help multiple-cursors-mappings
" let g:multi_cursor_use_default_mapping=0
" let g:multi_cursor_next_key='<C-n>'
" let g:multi_cursor_prev_key='<C-p>'
" let g:multi_cursor_skip_key='<C-x>'
" let g:multi_cursor_quit_key='<Esc>'
" Require a special keypress to enter multiple cursors mode
" let g:multi_cursor_start_key='+'
" }
" Use fork before if available {
if filereadable(expand("~/.vimrc.before.fork"))
source ~/.vimrc.before.fork
endif
" }
" Use local before if available {
if filereadable(expand("~/.vimrc.before.local"))
source ~/.vimrc.before.local
endif
" }