Open itgoyo opened 7 years ago
.vimrc
" 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 file of Steve Francia.
" While much of it is beneficial for general use, I would
" recommend picking out the parts you want and understand.
"
" You can find me at http://spf13.com
"
" Copyright 2014 Steve Francia
"
" Licensed under the Apache License, Version 2.0 (the "License");
" you may not use this file except in compliance with the License.
" You may obtain a copy of the License at
"
" http://www.apache.org/licenses/LICENSE-2.0
"
" Unless required by applicable law or agreed to in writing, software
" distributed under the License is distributed on an "AS IS" BASIS,
" WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
" See the License for the specific language governing permissions and
" limitations under the License.
" }
" Environment {
" Identify platform {
silent function! OSX()
return has('macunix')
endfunction
silent function! LINUX()
return has('unix') && !has('macunix') && !has('win32unix')
endfunction
silent function! WINDOWS()
return (has('win32') || has('win64'))
endfunction
" }
" Basics {
set nocompatible " Must be first line
if !WINDOWS()
set shell=/bin/sh
endif
" }
" Windows Compatible {
" On Windows, also use '.vim' instead of 'vimfiles'; this makes synchronization
" across (heterogeneous) systems easier.
if WINDOWS()
set runtimepath=$HOME/.vim,$VIM/vimfiles,$VIMRUNTIME,$VIM/vimfiles/after,$HOME/.vim/after
endif
" }
" Arrow Key Fix {
" https://github.com/spf13/spf13-vim/issues/780
if &term[:4] == "xterm" || &term[:5] == 'screen' || &term[:3] == 'rxvt'
inoremap <silent> <C-[>OC <RIGHT>
endif
" }
" }
" Use before config if available {
if filereadable(expand("~/.vimrc.before"))
source ~/.vimrc.before
endif
" }
" Use bundles config {
if filereadable(expand("~/.vimrc.bundles"))
source ~/.vimrc.bundles
endif
" }
" General {
set background=dark " Assume a dark background
" Allow to trigger background
function! ToggleBG()
let s:tbg = &background
" Inversion
if s:tbg == "dark"
set background=light
else
set background=dark
endif
endfunction
noremap <leader>bg :call ToggleBG()<CR>
" if !has('gui')
"set term=$TERM " Make arrow and other keys work
" endif
filetype plugin indent on " Automatically detect file types.
syntax on " Syntax highlighting
set mouse=a " Automatically enable mouse usage
set mousehide " Hide the mouse cursor while typing
scriptencoding utf-8
if has('clipboard')
if has('unnamedplus') " When possible use + register for copy-paste
set clipboard=unnamed,unnamedplus
else " On mac and Windows, use * register for copy-paste
set clipboard=unnamed
endif
endif
" Most prefer to automatically switch to the current file directory when
" a new buffer is opened; to prevent this behavior, add the following to
" your .vimrc.before.local file:
" let g:spf13_no_autochdir = 1
if !exists('g:spf13_no_autochdir')
autocmd BufEnter * if bufname("") !~ "^\[A-Za-z0-9\]*://" | lcd %:p:h | endif
" Always switch to the current file directory
endif
"set autowrite " Automatically write a file when leaving a modified buffer
set shortmess+=filmnrxoOtT " Abbrev. of messages (avoids 'hit enter')
set viewoptions=folds,options,cursor,unix,slash " Better Unix / Windows compatibility
set virtualedit=onemore " Allow for cursor beyond last character
set history=1000 " Store a ton of history (default is 20)
set spell " Spell checking on
set hidden " Allow buffer switching without saving
set iskeyword-=. " '.' is an end of word designator
set iskeyword-=# " '#' is an end of word designator
set iskeyword-=- " '-' is an end of word designator
" Instead of reverting the cursor to the last position in the buffer, we
" set it to the first line when editing a git commit message
au FileType gitcommit au! BufEnter COMMIT_EDITMSG call setpos('.', [0, 1, 1, 0])
" http://vim.wikia.com/wiki/Restore_cursor_to_file_position_in_previous_editing_session
" Restore cursor to file position in previous editing session
" To disable this, add the following to your .vimrc.before.local file:
" let g:spf13_no_restore_cursor = 1
if !exists('g:spf13_no_restore_cursor')
function! ResCur()
if line("'\"") <= line("$")
silent! normal! g`"
return 1
endif
endfunction
augroup resCur
autocmd!
autocmd BufWinEnter * call ResCur()
augroup END
endif
" Setting up the directories {
set backup " Backups are nice ...
if has('persistent_undo')
set undofile " So is persistent undo ...
set undolevels=1000 " Maximum number of changes that can be undone
set undoreload=10000 " Maximum number lines to save for undo on a buffer reload
endif
" To disable views add the following to your .vimrc.before.local file:
" let g:spf13_no_views = 1
if !exists('g:spf13_no_views')
" Add exclusions to mkview and loadview
" eg: *.*, svn-commit.tmp
let g:skipview_files = [
\ '\[example pattern\]'
\ ]
endif
" }
" }
" Vim UI {
if !exists('g:override_spf13_bundles') && filereadable(expand("~/.vim/bundle/vim-colors-solarized/colors/solarized.vim"))
let g:solarized_termcolors=256
let g:solarized_termtrans=1
let g:solarized_contrast="normal"
let g:solarized_visibility="normal"
color solarized " Load a colorscheme
endif
set tabpagemax=15 " Only show 15 tabs
set showmode " Display the current mode
set cursorline " Highlight current line
highlight clear SignColumn " SignColumn should match background
highlight clear LineNr " Current line number row will have same background color in relative mode
"highlight clear CursorLineNr " Remove highlight color from current line number
if has('cmdline_info')
set ruler " Show the ruler
set rulerformat=%30(%=\:b%n%y%m%r%w\ %l,%c%V\ %P%) " A ruler on steroids
set showcmd " Show partial commands in status line and
" Selected characters/lines in visual mode
endif
if has('statusline')
set laststatus=2
" Broken down into easily includeable segments
set statusline=%<%f\ " Filename
set statusline+=%w%h%m%r " Options
if !exists('g:override_spf13_bundles')
set statusline+=%{fugitive#statusline()} " Git Hotness
endif
set statusline+=\ [%{&ff}/%Y] " Filetype
set statusline+=\ [%{getcwd()}] " Current dir
set statusline+=%=%-14.(%l,%c%V%)\ %p%% " Right aligned file nav info
endif
set backspace=indent,eol,start " Backspace for dummies
set linespace=0 " No extra spaces between rows
set number " Line numbers on
set showmatch " Show matching brackets/parenthesis
set incsearch " Find as you type search
set hlsearch " Highlight search terms
set winminheight=0 " Windows can be 0 line high
set ignorecase " Case insensitive search
set smartcase " Case sensitive when uc present
set wildmenu " Show list instead of just completing
set wildmode=list:longest,full " Command <Tab> completion, list matches, then longest common part, then all.
set whichwrap=b,s,h,l,<,>,[,] " Backspace and cursor keys wrap too
set scrolljump=5 " Lines to scroll when cursor leaves screen
set scrolloff=3 " Minimum lines to keep above and below cursor
set foldenable " Auto fold code
set list
set listchars=tab:›\ ,trail:•,extends:#,nbsp:. " Highlight problematic whitespace
" }
" Formatting {
set nowrap " Do not wrap long lines
set autoindent " Indent at the same level of the previous line
set shiftwidth=4 " Use indents of 4 spaces
set expandtab " Tabs are spaces, not tabs
set tabstop=4 " An indentation every four columns
set softtabstop=4 " Let backspace delete indent
set nojoinspaces " Prevents inserting two spaces after punctuation on a join (J)
set splitright " Puts new vsplit windows to the right of the current
set splitbelow " Puts new split windows to the bottom of the current
"set matchpairs+=<:> " Match, to be used with %
set pastetoggle=<F12> " pastetoggle (sane indentation on pastes)
"set comments=sl:/*,mb:*,elx:*/ " auto format comment blocks
" Remove trailing whitespaces and ^M chars
" To disable the stripping of whitespace, add the following to your
" .vimrc.before.local file:
" let g:spf13_keep_trailing_whitespace = 1
autocmd FileType c,cpp,java,go,php,javascript,puppet,python,rust,twig,xml,yml,perl,sql autocmd BufWritePre <buffer> if !exists('g:spf13_keep_trailing_whitespace') | call StripTrailingWhitespace() | endif
"autocmd FileType go autocmd BufWritePre <buffer> Fmt
autocmd BufNewFile,BufRead *.html.twig set filetype=html.twig
autocmd FileType haskell,puppet,ruby,yml setlocal expandtab shiftwidth=2 softtabstop=2
" preceding line best in a plugin but here for now.
autocmd BufNewFile,BufRead *.coffee set filetype=coffee
" Workaround vim-commentary for Haskell
autocmd FileType haskell setlocal commentstring=--\ %s
" Workaround broken colour highlighting in Haskell
autocmd FileType haskell,rust setlocal nospell
" }
" Key (re)Mappings {
" The default leader is '\', but many people prefer ',' as it's in a standard
" location. To override this behavior and set it back to '\' (or any other
" character) add the following to your .vimrc.before.local file:
" let g:spf13_leader='\'
if !exists('g:spf13_leader')
let mapleader = ','
else
let mapleader=g:spf13_leader
endif
if !exists('g:spf13_localleader')
let maplocalleader = '_'
else
let maplocalleader=g:spf13_localleader
endif
" The default mappings for editing and applying the spf13 configuration
" are <leader>ev and <leader>sv respectively. Change them to your preference
" by adding the following to your .vimrc.before.local file:
" let g:spf13_edit_config_mapping='<leader>ec'
" let g:spf13_apply_config_mapping='<leader>sc'
if !exists('g:spf13_edit_config_mapping')
let s:spf13_edit_config_mapping = '<leader>ev'
else
let s:spf13_edit_config_mapping = g:spf13_edit_config_mapping
endif
if !exists('g:spf13_apply_config_mapping')
let s:spf13_apply_config_mapping = '<leader>sv'
else
let s:spf13_apply_config_mapping = g:spf13_apply_config_mapping
endif
" Easier moving in tabs and windows
" The lines conflict with the default digraph mapping of <C-K>
" If you prefer that functionality, add the following to your
" .vimrc.before.local file:
" let g:spf13_no_easyWindows = 1
if !exists('g:spf13_no_easyWindows')
map <C-J> <C-W>j<C-W>_
map <C-K> <C-W>k<C-W>_
map <C-L> <C-W>l<C-W>_
map <C-H> <C-W>h<C-W>_
endif
" Wrapped lines goes down/up to next row, rather than next line in file.
noremap j gj
noremap k gk
" End/Start of line motion keys act relative to row/wrap width in the
" presence of `:set wrap`, and relative to line for `:set nowrap`.
" Default vim behaviour is to act relative to text line in both cases
" If you prefer the default behaviour, add the following to your
" .vimrc.before.local file:
" let g:spf13_no_wrapRelMotion = 1
if !exists('g:spf13_no_wrapRelMotion')
" Same for 0, home, end, etc
function! WrapRelativeMotion(key, ...)
let vis_sel=""
if a:0
let vis_sel="gv"
endif
if &wrap
execute "normal!" vis_sel . "g" . a:key
else
execute "normal!" vis_sel . a:key
endif
endfunction
" Map g* keys in Normal, Operator-pending, and Visual+select
noremap $ :call WrapRelativeMotion("$")<CR>
noremap <End> :call WrapRelativeMotion("$")<CR>
noremap 0 :call WrapRelativeMotion("0")<CR>
noremap <Home> :call WrapRelativeMotion("0")<CR>
noremap ^ :call WrapRelativeMotion("^")<CR>
" Overwrite the operator pending $/<End> mappings from above
" to force inclusive motion with :execute normal!
onoremap $ v:call WrapRelativeMotion("$")<CR>
onoremap <End> v:call WrapRelativeMotion("$")<CR>
" Overwrite the Visual+select mode mappings from above
" to ensure the correct vis_sel flag is passed to function
vnoremap $ :<C-U>call WrapRelativeMotion("$", 1)<CR>
vnoremap <End> :<C-U>call WrapRelativeMotion("$", 1)<CR>
vnoremap 0 :<C-U>call WrapRelativeMotion("0", 1)<CR>
vnoremap <Home> :<C-U>call WrapRelativeMotion("0", 1)<CR>
vnoremap ^ :<C-U>call WrapRelativeMotion("^", 1)<CR>
endif
" The following two lines conflict with moving to top and
" bottom of the screen
" If you prefer that functionality, add the following to your
" .vimrc.before.local file:
" let g:spf13_no_fastTabs = 1
if !exists('g:spf13_no_fastTabs')
map <S-H> gT
map <S-L> gt
endif
" Stupid shift key fixes
if !exists('g:spf13_no_keyfixes')
if has("user_commands")
command! -bang -nargs=* -complete=file E e<bang> <args>
command! -bang -nargs=* -complete=file W w<bang> <args>
command! -bang -nargs=* -complete=file Wq wq<bang> <args>
command! -bang -nargs=* -complete=file WQ wq<bang> <args>
command! -bang Wa wa<bang>
command! -bang WA wa<bang>
command! -bang Q q<bang>
command! -bang QA qa<bang>
command! -bang Qa qa<bang>
endif
cmap Tabe tabe
endif
" Yank from the cursor to the end of the line, to be consistent with C and D.
nnoremap Y y$
" Code folding options
nmap <leader>f0 :set foldlevel=0<CR>
nmap <leader>f1 :set foldlevel=1<CR>
nmap <leader>f2 :set foldlevel=2<CR>
nmap <leader>f3 :set foldlevel=3<CR>
nmap <leader>f4 :set foldlevel=4<CR>
nmap <leader>f5 :set foldlevel=5<CR>
nmap <leader>f6 :set foldlevel=6<CR>
nmap <leader>f7 :set foldlevel=7<CR>
nmap <leader>f8 :set foldlevel=8<CR>
nmap <leader>f9 :set foldlevel=9<CR>
" Most prefer to toggle search highlighting rather than clear the current
" search results. To clear search highlighting rather than toggle it on
" and off, add the following to your .vimrc.before.local file:
" let g:spf13_clear_search_highlight = 1
if exists('g:spf13_clear_search_highlight')
nmap <silent> <leader>/ :nohlsearch<CR>
else
nmap <silent> <leader>/ :set invhlsearch<CR>
endif
" Find merge conflict markers
map <leader>fc /\v^[<\|=>]{7}( .*\|$)<CR>
" Shortcuts
" Change Working Directory to that of the current file
cmap cwd lcd %:p:h
cmap cd. lcd %:p:h
" Visual shifting (does not exit Visual mode)
vnoremap < <gv
vnoremap > >gv
" Allow using the repeat operator with a visual selection (!)
" http://stackoverflow.com/a/8064607/127816
vnoremap . :normal .<CR>
" For when you forget to sudo.. Really Write the file.
cmap w!! w !sudo tee % >/dev/null
" Some helpers to edit mode
" http://vimcasts.org/e/14
cnoremap %% <C-R>=fnameescape(expand('%:h')).'/'<cr>
map <leader>ew :e %%
map <leader>es :sp %%
map <leader>ev :vsp %%
map <leader>et :tabe %%
" Adjust viewports to the same size
map <Leader>= <C-w>=
" Map <Leader>ff to display all lines with keyword under cursor
" and ask which one to jump to
nmap <Leader>ff [I:let nr = input("Which one: ")<Bar>exe "normal " . nr ."[\t"<CR>
" Easier horizontal scrolling
map zl zL
map zh zH
" Easier formatting
nnoremap <silent> <leader>q gwip
" FIXME: Revert this f70be548
" fullscreen mode for GVIM and Terminal, need 'wmctrl' in you PATH
map <silent> <F11> :call system("wmctrl -ir " . v:windowid . " -b toggle,fullscreen")<CR>
" }
" Plugins {
" GoLang {
if count(g:spf13_bundle_groups, 'go')
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:go_fmt_command = "goimports"
let g:syntastic_go_checkers = ['golint', 'govet', 'errcheck']
let g:syntastic_mode_map = { 'mode': 'active', 'passive_filetypes': ['go'] }
au FileType go nmap <Leader>s <Plug>(go-implements)
au FileType go nmap <Leader>i <Plug>(go-info)
au FileType go nmap <Leader>e <Plug>(go-rename)
au FileType go nmap <leader>r <Plug>(go-run)
au FileType go nmap <leader>b <Plug>(go-build)
au FileType go nmap <leader>t <Plug>(go-test)
au FileType go nmap <Leader>gd <Plug>(go-doc)
au FileType go nmap <Leader>gv <Plug>(go-doc-vertical)
au FileType go nmap <leader>co <Plug>(go-coverage)
endif
" }
" TextObj Sentence {
if count(g:spf13_bundle_groups, 'writing')
augroup textobj_sentence
autocmd!
autocmd FileType markdown call textobj#sentence#init()
autocmd FileType textile call textobj#sentence#init()
autocmd FileType text call textobj#sentence#init()
augroup END
endif
" }
" TextObj Quote {
if count(g:spf13_bundle_groups, 'writing')
augroup textobj_quote
autocmd!
autocmd FileType markdown call textobj#quote#init()
autocmd FileType textile call textobj#quote#init()
autocmd FileType text call textobj#quote#init({'educate': 0})
augroup END
endif
" }
" PIV {
if isdirectory(expand("~/.vim/bundle/PIV"))
let g:DisableAutoPHPFolding = 0
let g:PIVAutoClose = 0
endif
" }
" Misc {
if isdirectory(expand("~/.vim/bundle/nerdtree"))
let g:NERDShutUp=1
endif
if isdirectory(expand("~/.vim/bundle/matchit.zip"))
let b:match_ignorecase = 1
endif
" }
" OmniComplete {
" To disable omni complete, add the following to your .vimrc.before.local file:
" let g:spf13_no_omni_complete = 1
if !exists('g:spf13_no_omni_complete')
if has("autocmd") && exists("+omnifunc")
autocmd Filetype *
\if &omnifunc == "" |
\setlocal omnifunc=syntaxcomplete#Complete |
\endif
endif
hi Pmenu guifg=#000000 guibg=#F8F8F8 ctermfg=black ctermbg=Lightgray
hi PmenuSbar guifg=#8A95A7 guibg=#F8F8F8 gui=NONE ctermfg=darkcyan ctermbg=lightgray cterm=NONE
hi PmenuThumb guifg=#F8F8F8 guibg=#8A95A7 gui=NONE ctermfg=lightgray ctermbg=darkcyan cterm=NONE
" Some convenient mappings
"inoremap <expr> <Esc> pumvisible() ? "\<C-e>" : "\<Esc>"
if exists('g:spf13_map_cr_omni_complete')
inoremap <expr> <CR> pumvisible() ? "\<C-y>" : "\<CR>"
endif
inoremap <expr> <Down> pumvisible() ? "\<C-n>" : "\<Down>"
inoremap <expr> <Up> pumvisible() ? "\<C-p>" : "\<Up>"
inoremap <expr> <C-d> pumvisible() ? "\<PageDown>\<C-p>\<C-n>" : "\<C-d>"
inoremap <expr> <C-u> pumvisible() ? "\<PageUp>\<C-p>\<C-n>" : "\<C-u>"
" Automatically open and close the popup menu / preview window
au CursorMovedI,InsertLeave * if pumvisible() == 0|silent! pclose|endif
set completeopt=menu,preview,longest
endif
" }
" Ctags {
set tags=./tags;/,~/.vimtags
" Make tags placed in .git/tags file available in all levels of a repository
let gitroot = substitute(system('git rev-parse --show-toplevel'), '[\n\r]', '', 'g')
if gitroot != ''
let &tags = &tags . ',' . gitroot . '/.git/tags'
endif
" }
" AutoCloseTag {
" Make it so AutoCloseTag works for xml and xhtml files as well
au FileType xhtml,xml ru ftplugin/html/autoclosetag.vim
nmap <Leader>ac <Plug>ToggleAutoCloseMappings
" }
" SnipMate {
" Setting the author var
" If forking, please overwrite in your .vimrc.local file
let g:snips_author = 'Steve Francia <steve.francia@gmail.com>'
" }
" NerdTree {
if isdirectory(expand("~/.vim/bundle/nerdtree"))
map <C-e> <plug>NERDTreeTabsToggle<CR>
map <leader>e :NERDTreeFind<CR>
nmap <leader>nt :NERDTreeFind<CR>
let NERDTreeShowBookmarks=1
let NERDTreeIgnore=['\.py[cd]$', '\~$', '\.swo$', '\.swp$', '^\.git$', '^\.hg$', '^\.svn$', '\.bzr$']
let NERDTreeChDirMode=0
let NERDTreeQuitOnOpen=1
let NERDTreeMouseMode=2
let NERDTreeShowHidden=1
let NERDTreeKeepTreeInNewTab=1
let g:nerdtree_tabs_open_on_gui_startup=0
endif
" }
" Tabularize {
if isdirectory(expand("~/.vim/bundle/tabular"))
nmap <Leader>a& :Tabularize /&<CR>
vmap <Leader>a& :Tabularize /&<CR>
nmap <Leader>a= :Tabularize /^[^=]*\zs=<CR>
vmap <Leader>a= :Tabularize /^[^=]*\zs=<CR>
nmap <Leader>a=> :Tabularize /=><CR>
vmap <Leader>a=> :Tabularize /=><CR>
nmap <Leader>a: :Tabularize /:<CR>
vmap <Leader>a: :Tabularize /:<CR>
nmap <Leader>a:: :Tabularize /:\zs<CR>
vmap <Leader>a:: :Tabularize /:\zs<CR>
nmap <Leader>a, :Tabularize /,<CR>
vmap <Leader>a, :Tabularize /,<CR>
nmap <Leader>a,, :Tabularize /,\zs<CR>
vmap <Leader>a,, :Tabularize /,\zs<CR>
nmap <Leader>a<Bar> :Tabularize /<Bar><CR>
vmap <Leader>a<Bar> :Tabularize /<Bar><CR>
endif
" }
" Session List {
set sessionoptions=blank,buffers,curdir,folds,tabpages,winsize
if isdirectory(expand("~/.vim/bundle/sessionman.vim/"))
nmap <leader>sl :SessionList<CR>
nmap <leader>ss :SessionSave<CR>
nmap <leader>sc :SessionClose<CR>
endif
" }
" JSON {
nmap <leader>jt <Esc>:%!python -m json.tool<CR><Esc>:set filetype=json<CR>
let g:vim_json_syntax_conceal = 0
" }
" PyMode {
" Disable if python support not present
if !has('python') && !has('python3')
let g:pymode = 0
endif
if isdirectory(expand("~/.vim/bundle/python-mode"))
let g:pymode_lint_checkers = ['pyflakes']
let g:pymode_trim_whitespaces = 0
let g:pymode_options = 0
let g:pymode_rope = 0
endif
" }
" ctrlp {
if isdirectory(expand("~/.vim/bundle/ctrlp.vim/"))
let g:ctrlp_working_path_mode = 'ra'
nnoremap <silent> <D-t> :CtrlP<CR>
nnoremap <silent> <D-r> :CtrlPMRU<CR>
let g:ctrlp_custom_ignore = {
\ 'dir': '\.git$\|\.hg$\|\.svn$',
\ 'file': '\.exe$\|\.so$\|\.dll$\|\.pyc$' }
if executable('ag')
let s:ctrlp_fallback = 'ag %s --nocolor -l -g ""'
elseif executable('ack-grep')
let s:ctrlp_fallback = 'ack-grep %s --nocolor -f'
elseif executable('ack')
let s:ctrlp_fallback = 'ack %s --nocolor -f'
" On Windows use "dir" as fallback command.
elseif WINDOWS()
let s:ctrlp_fallback = 'dir %s /-n /b /s /a-d'
else
let s:ctrlp_fallback = 'find %s -type f'
endif
if exists("g:ctrlp_user_command")
unlet g:ctrlp_user_command
endif
let g:ctrlp_user_command = {
\ 'types': {
\ 1: ['.git', 'cd %s && git ls-files . --cached --exclude-standard --others'],
\ 2: ['.hg', 'hg --cwd %s locate -I .'],
\ },
\ 'fallback': s:ctrlp_fallback
\ }
if isdirectory(expand("~/.vim/bundle/ctrlp-funky/"))
" CtrlP extensions
let g:ctrlp_extensions = ['funky']
"funky
nnoremap <Leader>fu :CtrlPFunky<Cr>
endif
endif
"}
" TagBar {
if isdirectory(expand("~/.vim/bundle/tagbar/"))
nnoremap <silent> <leader>tt :TagbarToggle<CR>
endif
"}
" Rainbow {
if isdirectory(expand("~/.vim/bundle/rainbow/"))
let g:rainbow_active = 1 "0 if you want to enable it later via :RainbowToggle
endif
"}
" Fugitive {
if isdirectory(expand("~/.vim/bundle/vim-fugitive/"))
nnoremap <silent> <leader>gs :Gstatus<CR>
nnoremap <silent> <leader>gd :Gdiff<CR>
nnoremap <silent> <leader>gc :Gcommit<CR>
nnoremap <silent> <leader>gb :Gblame<CR>
nnoremap <silent> <leader>gl :Glog<CR>
nnoremap <silent> <leader>gp :Git push<CR>
nnoremap <silent> <leader>gr :Gread<CR>
nnoremap <silent> <leader>gw :Gwrite<CR>
nnoremap <silent> <leader>ge :Gedit<CR>
" Mnemonic _i_nteractive
nnoremap <silent> <leader>gi :Git add -p %<CR>
nnoremap <silent> <leader>gg :SignifyToggle<CR>
endif
"}
" YouCompleteMe {
if count(g:spf13_bundle_groups, 'youcompleteme')
let g:acp_enableAtStartup = 0
" enable completion from tags
let g:ycm_collect_identifiers_from_tags_files = 1
let g:ycm_global_ycm_extra_conf='~/./bundle/YouCompleteMe/third_party/ycmd//ycm/.ycm_extra_conf.py'
" remap Ultisnips for compatibility for YCM
let g:UltiSnipsExpandTrigger = '<C-j>'
let g:UltiSnipsJumpForwardTrigger = '<C-j>'
let g:UltiSnipsJumpBackwardTrigger = '<C-k>'
" Enable omni completion.
autocmd FileType css setlocal omnifunc=csscomplete#CompleteCSS
autocmd FileType html,markdown setlocal omnifunc=htmlcomplete#CompleteTags
autocmd FileType javascript setlocal omnifunc=javascriptcomplete#CompleteJS
autocmd FileType python setlocal omnifunc=pythoncomplete#Complete
autocmd FileType xml setlocal omnifunc=xmlcomplete#CompleteTags
autocmd FileType ruby setlocal omnifunc=rubycomplete#Complete
autocmd FileType haskell setlocal omnifunc=necoghc#omnifunc
" Haskell post write lint and check with ghcmod
" $ `cabal install ghcmod` if missing and ensure
" ~/.cabal/bin is in your $PATH.
if !executable("ghcmod")
autocmd BufWritePost *.hs GhcModCheckAndLintAsync
endif
" For snippet_complete marker.
if !exists("g:spf13_no_conceal")
if has('conceal')
set conceallevel=2 concealcursor=i
endif
endif
" Disable the neosnippet preview candidate window
" When enabled, there can be too much visual noise
" especially when splits are used.
set completeopt-=preview
endif
" }
" neocomplete {
if count(g:spf13_bundle_groups, 'neocomplete')
let g:acp_enableAtStartup = 0
let g:neocomplete#enable_at_startup = 1
let g:neocomplete#enable_smart_case = 1
let g:neocomplete#enable_auto_delimiter = 1
let g:neocomplete#max_list = 15
let g:neocomplete#force_overwrite_completefunc = 1
" Define dictionary.
let g:neocomplete#sources#dictionary#dictionaries = {
\ 'default' : '',
\ 'vimshell' : $HOME.'/.vimshell_hist',
\ '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 {
" These two lines conflict with the default digraph mapping of <C-K>
if !exists('g:spf13_no_neosnippet_expand')
imap <C-k> <Plug>(neosnippet_expand_or_jump)
smap <C-k> <Plug>(neosnippet_expand_or_jump)
endif
if exists('g:spf13_noninvasive_completion')
inoremap <CR> <CR>
" <ESC> takes you out of insert mode
inoremap <expr> <Esc> pumvisible() ? "\<C-y>\<Esc>" : "\<Esc>"
" <CR> accepts first, then sends the <CR>
inoremap <expr> <CR> pumvisible() ? "\<C-y>\<CR>" : "\<CR>"
" <Down> and <Up> cycle like <Tab> and <S-Tab>
inoremap <expr> <Down> pumvisible() ? "\<C-n>" : "\<Down>"
inoremap <expr> <Up> pumvisible() ? "\<C-p>" : "\<Up>"
" Jump up and down the list
inoremap <expr> <C-d> pumvisible() ? "\<PageDown>\<C-p>\<C-n>" : "\<C-d>"
inoremap <expr> <C-u> pumvisible() ? "\<PageUp>\<C-p>\<C-n>" : "\<C-u>"
else
" <C-k> Complete Snippet
" <C-k> Jump to next snippet point
imap <silent><expr><C-k> neosnippet#expandable() ?
\ "\<Plug>(neosnippet_expand_or_jump)" : (pumvisible() ?
\ "\<C-e>" : "\<Plug>(neosnippet_expand_or_jump)")
smap <TAB> <Right><Plug>(neosnippet_jump_or_expand)
inoremap <expr><C-g> neocomplete#undo_completion()
inoremap <expr><C-l> neocomplete#complete_common_string()
"inoremap <expr><CR> neocomplete#complete_common_string()
" <CR>: close popup
" <s-CR>: close popup and save indent.
inoremap <expr><s-CR> pumvisible() ? neocomplete#smart_close_popup()."\<CR>" : "\<CR>"
function! CleverCr()
if pumvisible()
if neosnippet#expandable()
let exp = "\<Plug>(neosnippet_expand)"
return exp . neocomplete#smart_close_popup()
else
return neocomplete#smart_close_popup()
endif
else
return "\<CR>"
endif
endfunction
" <CR> close popup and save indent or expand snippet
imap <expr> <CR> CleverCr()
" <C-h>, <BS>: close popup and delete backword char.
inoremap <expr><BS> neocomplete#smart_close_popup()."\<C-h>"
inoremap <expr><C-y> neocomplete#smart_close_popup()
endif
" <TAB>: completion.
inoremap <expr><TAB> pumvisible() ? "\<C-n>" : "\<TAB>"
inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<TAB>"
" Courtesy of Matteo Cavalleri
function! CleverTab()
if pumvisible()
return "\<C-n>"
endif
let substr = strpart(getline('.'), 0, col('.') - 1)
let substr = matchstr(substr, '[^ \t]*$')
if strlen(substr) == 0
" nothing to match on empty string
return "\<Tab>"
else
" existing text matching
if neosnippet#expandable_or_jumpable()
return "\<Plug>(neosnippet_expand_or_jump)"
else
return neocomplete#start_manual_complete()
endif
endif
endfunction
imap <expr> <Tab> CleverTab()
" }
" Enable heavy omni completion.
if !exists('g:neocomplete#sources#omni#input_patterns')
let g:neocomplete#sources#omni#input_patterns = {}
endif
let g:neocomplete#sources#omni#input_patterns.php = '[^. \t]->\h\w*\|\h\w*::'
let g:neocomplete#sources#omni#input_patterns.perl = '\h\w*->\h\w*\|\h\w*::'
let g:neocomplete#sources#omni#input_patterns.c = '[^.[:digit:] *\t]\%(\.\|->\)'
let g:neocomplete#sources#omni#input_patterns.cpp = '[^.[:digit:] *\t]\%(\.\|->\)\|\h\w*::'
let g:neocomplete#sources#omni#input_patterns.ruby = '[^. *\t]\.\h\w*\|\h\w*::'
" }
" neocomplcache {
elseif count(g:spf13_bundle_groups, 'neocomplcache')
let g:acp_enableAtStartup = 0
let g:neocomplcache_enable_at_startup = 1
let g:neocomplcache_enable_camel_case_completion = 1
let g:neocomplcache_enable_smart_case = 1
let g:neocomplcache_enable_underbar_completion = 1
let g:neocomplcache_enable_auto_delimiter = 1
let g:neocomplcache_max_list = 15
let g:neocomplcache_force_overwrite_completefunc = 1
" Define dictionary.
let g:neocomplcache_dictionary_filetype_lists = {
\ 'default' : '',
\ 'vimshell' : $HOME.'/.vimshell_hist',
\ 'scheme' : $HOME.'/.gosh_completions'
\ }
" Define keyword.
if !exists('g:neocomplcache_keyword_patterns')
let g:neocomplcache_keyword_patterns = {}
endif
let g:neocomplcache_keyword_patterns._ = '\h\w*'
" Plugin key-mappings {
" These two lines conflict with the default digraph mapping of <C-K>
imap <C-k> <Plug>(neosnippet_expand_or_jump)
smap <C-k> <Plug>(neosnippet_expand_or_jump)
if exists('g:spf13_noninvasive_completion')
inoremap <CR> <CR>
" <ESC> takes you out of insert mode
inoremap <expr> <Esc> pumvisible() ? "\<C-y>\<Esc>" : "\<Esc>"
" <CR> accepts first, then sends the <CR>
inoremap <expr> <CR> pumvisible() ? "\<C-y>\<CR>" : "\<CR>"
" <Down> and <Up> cycle like <Tab> and <S-Tab>
inoremap <expr> <Down> pumvisible() ? "\<C-n>" : "\<Down>"
inoremap <expr> <Up> pumvisible() ? "\<C-p>" : "\<Up>"
" Jump up and down the list
inoremap <expr> <C-d> pumvisible() ? "\<PageDown>\<C-p>\<C-n>" : "\<C-d>"
inoremap <expr> <C-u> pumvisible() ? "\<PageUp>\<C-p>\<C-n>" : "\<C-u>"
else
imap <silent><expr><C-k> neosnippet#expandable() ?
\ "\<Plug>(neosnippet_expand_or_jump)" : (pumvisible() ?
\ "\<C-e>" : "\<Plug>(neosnippet_expand_or_jump)")
smap <TAB> <Right><Plug>(neosnippet_jump_or_expand)
inoremap <expr><C-g> neocomplcache#undo_completion()
inoremap <expr><C-l> neocomplcache#complete_common_string()
"inoremap <expr><CR> neocomplcache#complete_common_string()
function! CleverCr()
if pumvisible()
if neosnippet#expandable()
let exp = "\<Plug>(neosnippet_expand)"
return exp . neocomplcache#close_popup()
else
return neocomplcache#close_popup()
endif
else
return "\<CR>"
endif
endfunction
" <CR> close popup and save indent or expand snippet
imap <expr> <CR> CleverCr()
" <CR>: close popup
" <s-CR>: close popup and save indent.
inoremap <expr><s-CR> pumvisible() ? neocomplcache#close_popup()."\<CR>" : "\<CR>"
"inoremap <expr><CR> pumvisible() ? neocomplcache#close_popup() : "\<CR>"
" <C-h>, <BS>: close popup and delete backword char.
inoremap <expr><BS> neocomplcache#smart_close_popup()."\<C-h>"
inoremap <expr><C-y> neocomplcache#close_popup()
endif
" <TAB>: completion.
inoremap <expr><TAB> pumvisible() ? "\<C-n>" : "\<TAB>"
inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<TAB>"
" }
" Enable omni completion.
autocmd FileType css setlocal omnifunc=csscomplete#CompleteCSS
autocmd FileType html,markdown setlocal omnifunc=htmlcomplete#CompleteTags
autocmd FileType javascript setlocal omnifunc=javascriptcomplete#CompleteJS
autocmd FileType python setlocal omnifunc=pythoncomplete#Complete
autocmd FileType xml setlocal omnifunc=xmlcomplete#CompleteTags
autocmd FileType ruby setlocal omnifunc=rubycomplete#Complete
autocmd FileType haskell setlocal omnifunc=necoghc#omnifunc
" Enable heavy omni completion.
if !exists('g:neocomplcache_omni_patterns')
let g:neocomplcache_omni_patterns = {}
endif
let g:neocomplcache_omni_patterns.php = '[^. \t]->\h\w*\|\h\w*::'
let g:neocomplcache_omni_patterns.perl = '\h\w*->\h\w*\|\h\w*::'
let g:neocomplcache_omni_patterns.c = '[^.[:digit:] *\t]\%(\.\|->\)'
let g:neocomplcache_omni_patterns.cpp = '[^.[:digit:] *\t]\%(\.\|->\)\|\h\w*::'
let g:neocomplcache_omni_patterns.ruby = '[^. *\t]\.\h\w*\|\h\w*::'
let g:neocomplcache_omni_patterns.go = '\h\w*\.\?'
" }
" Normal Vim omni-completion {
" To disable omni complete, add the following to your .vimrc.before.local file:
" let g:spf13_no_omni_complete = 1
elseif !exists('g:spf13_no_omni_complete')
" Enable omni-completion.
autocmd FileType css setlocal omnifunc=csscomplete#CompleteCSS
autocmd FileType html,markdown setlocal omnifunc=htmlcomplete#CompleteTags
autocmd FileType javascript setlocal omnifunc=javascriptcomplete#CompleteJS
autocmd FileType python setlocal omnifunc=pythoncomplete#Complete
autocmd FileType xml setlocal omnifunc=xmlcomplete#CompleteTags
autocmd FileType ruby setlocal omnifunc=rubycomplete#Complete
autocmd FileType haskell setlocal omnifunc=necoghc#omnifunc
endif
" }
" Snippets {
if count(g:spf13_bundle_groups, 'neocomplcache') ||
\ count(g:spf13_bundle_groups, 'neocomplete')
" Use honza's snippets.
let g:neosnippet#snippets_directory='~/.vim/bundle/vim-snippets/snippets'
" Enable neosnippet snipmate compatibility mode
let g:neosnippet#enable_snipmate_compatibility = 1
" For snippet_complete marker.
if !exists("g:spf13_no_conceal")
if has('conceal')
set conceallevel=2 concealcursor=i
endif
endif
" Enable neosnippets when using go
let g:go_snippet_engine = "neosnippet"
" Disable the neosnippet preview candidate window
" When enabled, there can be too much visual noise
" especially when splits are used.
set completeopt-=preview
endif
" }
" FIXME: Isn't this for Syntastic to handle?
" Haskell post write lint and check with ghcmod
" $ `cabal install ghcmod` if missing and ensure
" ~/.cabal/bin is in your $PATH.
if !executable("ghcmod")
autocmd BufWritePost *.hs GhcModCheckAndLintAsync
endif
" UndoTree {
if isdirectory(expand("~/.vim/bundle/undotree/"))
nnoremap <Leader>u :UndotreeToggle<CR>
" If undotree is opened, it is likely one wants to interact with it.
let g:undotree_SetFocusWhenToggle=1
endif
" }
" indent_guides {
if isdirectory(expand("~/.vim/bundle/vim-indent-guides/"))
let g:indent_guides_start_level = 2
let g:indent_guides_guide_size = 1
let g:indent_guides_enable_on_vim_startup = 1
endif
" }
" Wildfire {
let g:wildfire_objects = {
\ "*" : ["i'", 'i"', "i)", "i]", "i}", "ip"],
\ "html,xml" : ["at"],
\ }
" }
" vim-airline {
" Set configuration options for the statusline plugin vim-airline.
" Use the powerline theme and optionally enable powerline symbols.
" To use the symbols , , , , , , and .in the statusline
" segments add the following to your .vimrc.before.local file:
" let g:airline_powerline_fonts=1
" If the previous symbols do not render for you then install a
" powerline enabled font.
" See `:echo g:airline_theme_map` for some more choices
" Default in terminal vim is 'dark'
if isdirectory(expand("~/.vim/bundle/vim-airline-themes/"))
if !exists('g:airline_theme')
" let g:airline_theme = 'solarized'
let g:airline_theme = 'dark'
endif
if !exists('g:airline_powerline_fonts')
" Use the default set of separators with a few customizations
let g:airline_left_sep='›' " Slightly fancier than '>'
let g:airline_right_sep='‹' " Slightly fancier than '<'
endif
endif
" }
" }
" GUI Settings {
" GVIM- (here instead of .gvimrc)
if has('gui_running')
set guioptions-=T " Remove the toolbar
set lines=40 " 40 lines of text instead of 24
if !exists("g:spf13_no_big_font")
if LINUX() && has("gui_running")
set guifont=Andale\ Mono\ Regular\ 12,Menlo\ Regular\ 11,Consolas\ Regular\ 12,Courier\ New\ Regular\ 14
elseif OSX() && has("gui_running")
set guifont=Andale\ Mono\ Regular:h12,Menlo\ Regular:h11,Consolas\ Regular:h12,Courier\ New\ Regular:h14
elseif WINDOWS() && has("gui_running")
set guifont=Andale_Mono:h10,Menlo:h10,Consolas:h10,Courier_New:h10
endif
endif
else
if &term == 'xterm' || &term == 'screen'
set t_Co=256 " Enable 256 colors to stop the CSApprox warning and make xterm vim shine
endif
"set term=builtin_ansi " Make arrow and other keys work
endif
" }
" Functions {
" Initialize directories {
function! InitializeDirectories()
let parent = $HOME
let prefix = 'vim'
let dir_list = {
\ 'backup': 'backupdir',
\ 'views': 'viewdir',
\ 'swap': 'directory' }
if has('persistent_undo')
let dir_list['undo'] = 'undodir'
endif
" To specify a different directory in which to place the vimbackup,
" vimviews, vimundo, and vimswap files/directories, add the following to
" your .vimrc.before.local file:
" let g:spf13_consolidated_directory = <full path to desired directory>
" eg: let g:spf13_consolidated_directory = $HOME . '/.vim/'
if exists('g:spf13_consolidated_directory')
let common_dir = g:spf13_consolidated_directory . prefix
else
let common_dir = parent . '/.' . prefix
endif
for [dirname, settingname] in items(dir_list)
let directory = common_dir . dirname . '/'
if exists("*mkdir")
if !isdirectory(directory)
call mkdir(directory)
endif
endif
if !isdirectory(directory)
echo "Warning: Unable to create backup directory: " . directory
echo "Try: mkdir -p " . directory
else
let directory = substitute(directory, " ", "\\\\ ", "g")
exec "set " . settingname . "=" . directory
endif
endfor
endfunction
call InitializeDirectories()
" }
" Initialize NERDTree as needed {
function! NERDTreeInitAsNeeded()
redir => bufoutput
buffers!
redir END
let idx = stridx(bufoutput, "NERD_tree")
if idx > -1
NERDTreeMirror
NERDTreeFind
wincmd l
endif
endfunction
" }
" Strip whitespace {
function! StripTrailingWhitespace()
" Preparation: save last search, and cursor position.
let _s=@/
let l = line(".")
let c = col(".")
" do the business:
%s/\s\+$//e
" clean up: restore previous search history, and cursor position
let @/=_s
call cursor(l, c)
endfunction
" }
" Shell command {
function! s:RunShellCommand(cmdline)
botright new
setlocal buftype=nofile
setlocal bufhidden=delete
setlocal nobuflisted
setlocal noswapfile
setlocal nowrap
setlocal filetype=shell
setlocal syntax=shell
call setline(1, a:cmdline)
call setline(2, substitute(a:cmdline, '.', '=', 'g'))
execute 'silent $read !' . escape(a:cmdline, '%#')
setlocal nomodifiable
1
endfunction
command! -complete=file -nargs=+ Shell call s:RunShellCommand(<q-args>)
" e.g. Grep current file for <search_term>: Shell grep -Hn <search_term> %
" }
function! s:IsSpf13Fork()
let s:is_fork = 0
let s:fork_files = ["~/.vimrc.fork", "~/.vimrc.before.fork", "~/.vimrc.bundles.fork"]
for fork_file in s:fork_files
if filereadable(expand(fork_file, ":p"))
let s:is_fork = 1
break
endif
endfor
return s:is_fork
endfunction
function! s:ExpandFilenameAndExecute(command, file)
execute a:command . " " . expand(a:file, ":p")
endfunction
function! s:EditSpf13Config()
call <SID>ExpandFilenameAndExecute("tabedit", "~/.vimrc")
call <SID>ExpandFilenameAndExecute("vsplit", "~/.vimrc.before")
call <SID>ExpandFilenameAndExecute("vsplit", "~/.vimrc.bundles")
execute bufwinnr(".vimrc") . "wincmd w"
call <SID>ExpandFilenameAndExecute("split", "~/.vimrc.local")
wincmd l
call <SID>ExpandFilenameAndExecute("split", "~/.vimrc.before.local")
wincmd l
call <SID>ExpandFilenameAndExecute("split", "~/.vimrc.bundles.local")
if <SID>IsSpf13Fork()
execute bufwinnr(".vimrc") . "wincmd w"
call <SID>ExpandFilenameAndExecute("split", "~/.vimrc.fork")
wincmd l
call <SID>ExpandFilenameAndExecute("split", "~/.vimrc.before.fork")
wincmd l
call <SID>ExpandFilenameAndExecute("split", "~/.vimrc.bundles.fork")
endif
execute bufwinnr(".vimrc.local") . "wincmd w"
endfunction
execute "noremap " . s:spf13_edit_config_mapping " :call <SID>EditSpf13Config()<CR>"
execute "noremap " . s:spf13_apply_config_mapping . " :source ~/.vimrc<CR>"
" }
" Use fork vimrc if available {
if filereadable(expand("~/.vimrc.fork"))
source ~/.vimrc.fork
endif
" }
" Use local vimrc if available {
if filereadable(expand("~/.vimrc.local"))
source ~/.vimrc.local
endif
" }
" Use local gvimrc if available and gui is running {
if has('gui_running')
if filereadable(expand("~/.gvimrc.local"))
source ~/.gvimrc.local
endif
endif
" }
Plugin 'morhetz/gruvbox'
set bg=dark
colorscheme gruvbox
"设置相对行号
set relativenumber
Plugin 'Valloric/YouCompleteMe'
let g:ycm_global_ycm_extra_conf = '~/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp/ycm/.ycm_extra_conf.py'
Plugin 'iamcco/markdown-preview.vim'
Plugin 'airblade/vim-gitgutter'
exec 'cd ' . fnameescape('/Users/itgoyo/Documents/Vim')
set rtp+=/usr/local/opt/fzf
"Plugin '/usr/local/opt/fzf'
set rtp+=/home/itgoyo/.fzf/
Plugin 'junegunn/fzf.vim'
" 切换buffer
nnoremap <silent> [b :bprevious<CR>
nnoremap <silent> [n :bnext<CR>
" use ctrl+hjkl switch window
:noremap <C-h> <C-w>h
:noremap <C-j> <C-w>j
:noremap <C-k> <C-w>k
:noremap <C-l> <C-w>l
"使用leader+w 直接保存
"inoremap <leader>w <Esc>:w<cr>
"noremap <leader>w :w<cr>
:noremap <D-S> :w<cr>
:noremap <leader>s :w<cr>
":noremap <leader>s :w<cr>
:noremap <leader>p :MarkdownPreview<cr>
"Mode Settings
let &t_SI.="\e[5 q" "SI = INSERT mode
let &t_SR.="\e[4 q" "SR = REPLACE mode
let &t_EI.="\e[1 q" "EI = NORMAL mode (ELSE)
"Cursor settings:
" 1 -> blinking block
" 2 -> solid block
" 3 -> blinking underscore
" 4 -> solid underscore
" 5 -> blinking vertical bar
" 6 -> solid vertical bar
"let &t_SI = "\<Esc>]50;CursorShape=1\x7"
"let &t_SR = "\<Esc>]50;CursorShape=2\x7"
"let &t_EI = "\<Esc>]50;CursorShape=0\x7"
家里电脑的.vimrc
" 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 file of Steve Francia.
" While much of it is beneficial for general use, I would
" recommend picking out the parts you want and understand.
"
" You can find me at http://spf13.com
"
" Copyright 2014 Steve Francia
"
" Licensed under the Apache License, Version 2.0 (the "License");
" you may not use this file except in compliance with the License.
" You may obtain a copy of the License at
"
" http://www.apache.org/licenses/LICENSE-2.0
"
" Unless required by applicable law or agreed to in writing, software
" distributed under the License is distributed on an "AS IS" BASIS,
" WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
" See the License for the specific language governing permissions and
" limitations under the License.
" }
" Environment {
" Identify platform {
silent function! OSX()
return has('macunix')
endfunction
silent function! LINUX()
return has('unix') && !has('macunix') && !has('win32unix')
endfunction
silent function! WINDOWS()
return (has('win32') || has('win64'))
endfunction
" }
" Basics {
set nocompatible " Must be first line
if !WINDOWS()
set shell=/bin/sh
endif
" }
" Windows Compatible {
" On Windows, also use '.vim' instead of 'vimfiles'; this makes synchronization
" across (heterogeneous) systems easier.
if WINDOWS()
set runtimepath=$HOME/.vim,$VIM/vimfiles,$VIMRUNTIME,$VIM/vimfiles/after,$HOME/.vim/after
endif
" }
" Arrow Key Fix {
" https://github.com/spf13/spf13-vim/issues/780
if &term[:4] == "xterm" || &term[:5] == 'screen' || &term[:3] == 'rxvt'
inoremap <silent> <C-[>OC <RIGHT>
endif
" }
" }
" Use before config if available {
if filereadable(expand("~/.vimrc.before"))
source ~/.vimrc.before
endif
" }
" Use bundles config {
if filereadable(expand("~/.vimrc.bundles"))
source ~/.vimrc.bundles
endif
" }
" General {
set background=dark " Assume a dark background
" Allow to trigger background
function! ToggleBG()
let s:tbg = &background
" Inversion
if s:tbg == "dark"
set background=light
else
set background=dark
endif
endfunction
noremap <leader>bg :call ToggleBG()<CR>
" if !has('gui')
"set term=$TERM " Make arrow and other keys work
" endif
filetype plugin indent on " Automatically detect file types.
syntax on " Syntax highlighting
set mouse=a " Automatically enable mouse usage
set mousehide " Hide the mouse cursor while typing
scriptencoding utf-8
if has('clipboard')
if has('unnamedplus') " When possible use + register for copy-paste
set clipboard=unnamed,unnamedplus
else " On mac and Windows, use * register for copy-paste
set clipboard=unnamed
endif
endif
" Most prefer to automatically switch to the current file directory when
" a new buffer is opened; to prevent this behavior, add the following to
" your .vimrc.before.local file:
" let g:spf13_no_autochdir = 1
if !exists('g:spf13_no_autochdir')
autocmd BufEnter * if bufname("") !~ "^\[A-Za-z0-9\]*://" | lcd %:p:h | endif
" Always switch to the current file directory
endif
"set autowrite " Automatically write a file when leaving a modified buffer
set shortmess+=filmnrxoOtT " Abbrev. of messages (avoids 'hit enter')
set viewoptions=folds,options,cursor,unix,slash " Better Unix / Windows compatibility
set virtualedit=onemore " Allow for cursor beyond last character
set history=1000 " Store a ton of history (default is 20)
set spell " Spell checking on
set hidden " Allow buffer switching without saving
set iskeyword-=. " '.' is an end of word designator
set iskeyword-=# " '#' is an end of word designator
set iskeyword-=- " '-' is an end of word designator
" Instead of reverting the cursor to the last position in the buffer, we
" set it to the first line when editing a git commit message
au FileType gitcommit au! BufEnter COMMIT_EDITMSG call setpos('.', [0, 1, 1, 0])
" http://vim.wikia.com/wiki/Restore_cursor_to_file_position_in_previous_editing_session
" Restore cursor to file position in previous editing session
" To disable this, add the following to your .vimrc.before.local file:
" let g:spf13_no_restore_cursor = 1
if !exists('g:spf13_no_restore_cursor')
function! ResCur()
if line("'\"") <= line("$")
silent! normal! g`"
return 1
endif
endfunction
augroup resCur
autocmd!
autocmd BufWinEnter * call ResCur()
augroup END
endif
" Setting up the directories {
set backup " Backups are nice ...
if has('persistent_undo')
set undofile " So is persistent undo ...
set undolevels=1000 " Maximum number of changes that can be undone
set undoreload=10000 " Maximum number lines to save for undo on a buffer reload
endif
" To disable views add the following to your .vimrc.before.local file:
" let g:spf13_no_views = 1
if !exists('g:spf13_no_views')
" Add exclusions to mkview and loadview
" eg: *.*, svn-commit.tmp
let g:skipview_files = [
\ '\[example pattern\]'
\ ]
endif
" }
" }
" Vim UI {
if !exists('g:override_spf13_bundles') && filereadable(expand("~/.vim/bundle/vim-colors-solarized/colors/solarized.vim"))
let g:solarized_termcolors=256
let g:solarized_termtrans=1
let g:solarized_contrast="normal"
let g:solarized_visibility="normal"
color solarized " Load a colorscheme
endif
set tabpagemax=15 " Only show 15 tabs
set showmode " Display the current mode
set cursorline " Highlight current line
highlight clear SignColumn " SignColumn should match background
highlight clear LineNr " Current line number row will have same background color in relative mode
"highlight clear CursorLineNr " Remove highlight color from current line number
if has('cmdline_info')
set ruler " Show the ruler
set rulerformat=%30(%=\:b%n%y%m%r%w\ %l,%c%V\ %P%) " A ruler on steroids
set showcmd " Show partial commands in status line and
" Selected characters/lines in visual mode
endif
if has('statusline')
set laststatus=2
" Broken down into easily includeable segments
set statusline=%<%f\ " Filename
set statusline+=%w%h%m%r " Options
if !exists('g:override_spf13_bundles')
set statusline+=%{fugitive#statusline()} " Git Hotness
endif
set statusline+=\ [%{&ff}/%Y] " Filetype
set statusline+=\ [%{getcwd()}] " Current dir
set statusline+=%=%-14.(%l,%c%V%)\ %p%% " Right aligned file nav info
endif
set backspace=indent,eol,start " Backspace for dummies
set linespace=0 " No extra spaces between rows
set number " Line numbers on
set showmatch " Show matching brackets/parenthesis
set incsearch " Find as you type search
set hlsearch " Highlight search terms
set winminheight=0 " Windows can be 0 line high
set ignorecase " Case insensitive search
set smartcase " Case sensitive when uc present
set wildmenu " Show list instead of just completing
set wildmode=list:longest,full " Command <Tab> completion, list matches, then longest common part, then all.
set whichwrap=b,s,h,l,<,>,[,] " Backspace and cursor keys wrap too
set scrolljump=5 " Lines to scroll when cursor leaves screen
set scrolloff=3 " Minimum lines to keep above and below cursor
set foldenable " Auto fold code
set list
set listchars=tab:›\ ,trail:•,extends:#,nbsp:. " Highlight problematic whitespace
" }
" Formatting {
set nowrap " Do not wrap long lines
set autoindent " Indent at the same level of the previous line
set shiftwidth=4 " Use indents of 4 spaces
set expandtab " Tabs are spaces, not tabs
set tabstop=4 " An indentation every four columns
set softtabstop=4 " Let backspace delete indent
set nojoinspaces " Prevents inserting two spaces after punctuation on a join (J)
set splitright " Puts new vsplit windows to the right of the current
set splitbelow " Puts new split windows to the bottom of the current
"set matchpairs+=<:> " Match, to be used with %
set pastetoggle=<F12> " pastetoggle (sane indentation on pastes)
"set comments=sl:/*,mb:*,elx:*/ " auto format comment blocks
" Remove trailing whitespaces and ^M chars
" To disable the stripping of whitespace, add the following to your
" .vimrc.before.local file:
" let g:spf13_keep_trailing_whitespace = 1
autocmd FileType c,cpp,java,go,php,javascript,puppet,python,rust,twig,xml,yml,perl,sql autocmd BufWritePre <buffer> if !exists('g:spf13_keep_trailing_whitespace') | call StripTrailingWhitespace() | endif
"autocmd FileType go autocmd BufWritePre <buffer> Fmt
autocmd BufNewFile,BufRead *.html.twig set filetype=html.twig
autocmd FileType haskell,puppet,ruby,yml setlocal expandtab shiftwidth=2 softtabstop=2
" preceding line best in a plugin but here for now.
autocmd BufNewFile,BufRead *.coffee set filetype=coffee
" Workaround vim-commentary for Haskell
autocmd FileType haskell setlocal commentstring=--\ %s
" Workaround broken colour highlighting in Haskell
autocmd FileType haskell,rust setlocal nospell
" }
" Key (re)Mappings {
" The default leader is '\', but many people prefer ',' as it's in a standard
" location. To override this behavior and set it back to '\' (or any other
" character) add the following to your .vimrc.before.local file:
" let g:spf13_leader='\'
if !exists('g:spf13_leader')
let mapleader = ','
else
let mapleader=g:spf13_leader
endif
if !exists('g:spf13_localleader')
let maplocalleader = '_'
else
let maplocalleader=g:spf13_localleader
endif
" The default mappings for editing and applying the spf13 configuration
" are <leader>ev and <leader>sv respectively. Change them to your preference
" by adding the following to your .vimrc.before.local file:
" let g:spf13_edit_config_mapping='<leader>ec'
" let g:spf13_apply_config_mapping='<leader>sc'
if !exists('g:spf13_edit_config_mapping')
let s:spf13_edit_config_mapping = '<leader>ev'
else
let s:spf13_edit_config_mapping = g:spf13_edit_config_mapping
endif
if !exists('g:spf13_apply_config_mapping')
let s:spf13_apply_config_mapping = '<leader>sv'
else
let s:spf13_apply_config_mapping = g:spf13_apply_config_mapping
endif
" Easier moving in tabs and windows
" The lines conflict with the default digraph mapping of <C-K>
" If you prefer that functionality, add the following to your
" .vimrc.before.local file:
" let g:spf13_no_easyWindows = 1
if !exists('g:spf13_no_easyWindows')
map <C-J> <C-W>j<C-W>_
map <C-K> <C-W>k<C-W>_
map <C-L> <C-W>l<C-W>_
map <C-H> <C-W>h<C-W>_
endif
" Wrapped lines goes down/up to next row, rather than next line in file.
noremap j gj
noremap k gk
" End/Start of line motion keys act relative to row/wrap width in the
" presence of `:set wrap`, and relative to line for `:set nowrap`.
" Default vim behaviour is to act relative to text line in both cases
" If you prefer the default behaviour, add the following to your
" .vimrc.before.local file:
" let g:spf13_no_wrapRelMotion = 1
if !exists('g:spf13_no_wrapRelMotion')
" Same for 0, home, end, etc
function! WrapRelativeMotion(key, ...)
let vis_sel=""
if a:0
let vis_sel="gv"
endif
if &wrap
execute "normal!" vis_sel . "g" . a:key
else
execute "normal!" vis_sel . a:key
endif
endfunction
" Map g* keys in Normal, Operator-pending, and Visual+select
noremap $ :call WrapRelativeMotion("$")<CR>
noremap <End> :call WrapRelativeMotion("$")<CR>
noremap 0 :call WrapRelativeMotion("0")<CR>
noremap <Home> :call WrapRelativeMotion("0")<CR>
noremap ^ :call WrapRelativeMotion("^")<CR>
" Overwrite the operator pending $/<End> mappings from above
" to force inclusive motion with :execute normal!
onoremap $ v:call WrapRelativeMotion("$")<CR>
onoremap <End> v:call WrapRelativeMotion("$")<CR>
" Overwrite the Visual+select mode mappings from above
" to ensure the correct vis_sel flag is passed to function
vnoremap $ :<C-U>call WrapRelativeMotion("$", 1)<CR>
vnoremap <End> :<C-U>call WrapRelativeMotion("$", 1)<CR>
vnoremap 0 :<C-U>call WrapRelativeMotion("0", 1)<CR>
vnoremap <Home> :<C-U>call WrapRelativeMotion("0", 1)<CR>
vnoremap ^ :<C-U>call WrapRelativeMotion("^", 1)<CR>
endif
" The following two lines conflict with moving to top and
" bottom of the screen
" If you prefer that functionality, add the following to your
" .vimrc.before.local file:
" let g:spf13_no_fastTabs = 1
if !exists('g:spf13_no_fastTabs')
map <S-H> gT
map <S-L> gt
endif
" Stupid shift key fixes
if !exists('g:spf13_no_keyfixes')
if has("user_commands")
command! -bang -nargs=* -complete=file E e<bang> <args>
command! -bang -nargs=* -complete=file W w<bang> <args>
command! -bang -nargs=* -complete=file Wq wq<bang> <args>
command! -bang -nargs=* -complete=file WQ wq<bang> <args>
command! -bang Wa wa<bang>
command! -bang WA wa<bang>
command! -bang Q q<bang>
command! -bang QA qa<bang>
command! -bang Qa qa<bang>
endif
cmap Tabe tabe
endif
" Yank from the cursor to the end of the line, to be consistent with C and D.
nnoremap Y y$
" Code folding options
nmap <leader>f0 :set foldlevel=0<CR>
nmap <leader>f1 :set foldlevel=1<CR>
nmap <leader>f2 :set foldlevel=2<CR>
nmap <leader>f3 :set foldlevel=3<CR>
nmap <leader>f4 :set foldlevel=4<CR>
nmap <leader>f5 :set foldlevel=5<CR>
nmap <leader>f6 :set foldlevel=6<CR>
nmap <leader>f7 :set foldlevel=7<CR>
nmap <leader>f8 :set foldlevel=8<CR>
nmap <leader>f9 :set foldlevel=9<CR>
" Most prefer to toggle search highlighting rather than clear the current
" search results. To clear search highlighting rather than toggle it on
" and off, add the following to your .vimrc.before.local file:
" let g:spf13_clear_search_highlight = 1
if exists('g:spf13_clear_search_highlight')
nmap <silent> <leader>/ :nohlsearch<CR>
else
nmap <silent> <leader>/ :set invhlsearch<CR>
endif
" Find merge conflict markers
map <leader>fc /\v^[<\|=>]{7}( .*\|$)<CR>
" Shortcuts
" Change Working Directory to that of the current file
cmap cwd lcd %:p:h
cmap cd. lcd %:p:h
" Visual shifting (does not exit Visual mode)
vnoremap < <gv
vnoremap > >gv
" Allow using the repeat operator with a visual selection (!)
" http://stackoverflow.com/a/8064607/127816
vnoremap . :normal .<CR>
" For when you forget to sudo.. Really Write the file.
cmap w!! w !sudo tee % >/dev/null
" Some helpers to edit mode
" http://vimcasts.org/e/14
cnoremap %% <C-R>=fnameescape(expand('%:h')).'/'<cr>
map <leader>ew :e %%
map <leader>es :sp %%
map <leader>ev :vsp %%
map <leader>et :tabe %%
" Adjust viewports to the same size
map <Leader>= <C-w>=
" Map <Leader>ff to display all lines with keyword under cursor
" and ask which one to jump to
nmap <Leader>ff [I:let nr = input("Which one: ")<Bar>exe "normal " . nr ."[\t"<CR>
" Easier horizontal scrolling
map zl zL
map zh zH
" Easier formatting
nnoremap <silent> <leader>q gwip
" FIXME: Revert this f70be548
" fullscreen mode for GVIM and Terminal, need 'wmctrl' in you PATH
map <silent> <F11> :call system("wmctrl -ir " . v:windowid . " -b toggle,fullscreen")<CR>
" }
" Plugins {
" GoLang {
if count(g:spf13_bundle_groups, 'go')
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:go_fmt_command = "goimports"
let g:syntastic_go_checkers = ['golint', 'govet', 'errcheck']
let g:syntastic_mode_map = { 'mode': 'active', 'passive_filetypes': ['go'] }
au FileType go nmap <Leader>s <Plug>(go-implements)
au FileType go nmap <Leader>i <Plug>(go-info)
au FileType go nmap <Leader>e <Plug>(go-rename)
au FileType go nmap <leader>r <Plug>(go-run)
au FileType go nmap <leader>b <Plug>(go-build)
au FileType go nmap <leader>t <Plug>(go-test)
au FileType go nmap <Leader>gd <Plug>(go-doc)
au FileType go nmap <Leader>gv <Plug>(go-doc-vertical)
au FileType go nmap <leader>co <Plug>(go-coverage)
endif
" }
" TextObj Sentence {
if count(g:spf13_bundle_groups, 'writing')
augroup textobj_sentence
autocmd!
autocmd FileType markdown call textobj#sentence#init()
autocmd FileType textile call textobj#sentence#init()
autocmd FileType text call textobj#sentence#init()
augroup END
endif
" }
" TextObj Quote {
if count(g:spf13_bundle_groups, 'writing')
augroup textobj_quote
autocmd!
autocmd FileType markdown call textobj#quote#init()
autocmd FileType textile call textobj#quote#init()
autocmd FileType text call textobj#quote#init({'educate': 0})
augroup END
endif
" }
" PIV {
if isdirectory(expand("~/.vim/bundle/PIV"))
let g:DisableAutoPHPFolding = 0
let g:PIVAutoClose = 0
endif
" }
" Misc {
if isdirectory(expand("~/.vim/bundle/nerdtree"))
let g:NERDShutUp=1
endif
if isdirectory(expand("~/.vim/bundle/matchit.zip"))
let b:match_ignorecase = 1
endif
" }
" OmniComplete {
" To disable omni complete, add the following to your .vimrc.before.local file:
" let g:spf13_no_omni_complete = 1
if !exists('g:spf13_no_omni_complete')
if has("autocmd") && exists("+omnifunc")
autocmd Filetype *
\if &omnifunc == "" |
\setlocal omnifunc=syntaxcomplete#Complete |
\endif
endif
hi Pmenu guifg=#000000 guibg=#F8F8F8 ctermfg=black ctermbg=Lightgray
hi PmenuSbar guifg=#8A95A7 guibg=#F8F8F8 gui=NONE ctermfg=darkcyan ctermbg=lightgray cterm=NONE
hi PmenuThumb guifg=#F8F8F8 guibg=#8A95A7 gui=NONE ctermfg=lightgray ctermbg=darkcyan cterm=NONE
" Some convenient mappings
"inoremap <expr> <Esc> pumvisible() ? "\<C-e>" : "\<Esc>"
if exists('g:spf13_map_cr_omni_complete')
inoremap <expr> <CR> pumvisible() ? "\<C-y>" : "\<CR>"
endif
inoremap <expr> <Down> pumvisible() ? "\<C-n>" : "\<Down>"
inoremap <expr> <Up> pumvisible() ? "\<C-p>" : "\<Up>"
inoremap <expr> <C-d> pumvisible() ? "\<PageDown>\<C-p>\<C-n>" : "\<C-d>"
inoremap <expr> <C-u> pumvisible() ? "\<PageUp>\<C-p>\<C-n>" : "\<C-u>"
" Automatically open and close the popup menu / preview window
au CursorMovedI,InsertLeave * if pumvisible() == 0|silent! pclose|endif
set completeopt=menu,preview,longest
endif
" }
" Ctags {
set tags=./tags;/,~/.vimtags
" Make tags placed in .git/tags file available in all levels of a repository
let gitroot = substitute(system('git rev-parse --show-toplevel'), '[\n\r]', '', 'g')
if gitroot != ''
let &tags = &tags . ',' . gitroot . '/.git/tags'
endif
" }
" AutoCloseTag {
" Make it so AutoCloseTag works for xml and xhtml files as well
au FileType xhtml,xml ru ftplugin/html/autoclosetag.vim
nmap <Leader>ac <Plug>ToggleAutoCloseMappings
" }
" SnipMate {
" Setting the author var
" If forking, please overwrite in your .vimrc.local file
let g:snips_author = 'Steve Francia <steve.francia@gmail.com>'
" }
" NerdTree {
if isdirectory(expand("~/.vim/bundle/nerdtree"))
map <C-e> <plug>NERDTreeTabsToggle<CR>
map <leader>e :NERDTreeFind<CR>
nmap <leader>nt :NERDTreeFind<CR>
let NERDTreeShowBookmarks=1
let NERDTreeIgnore=['\.py[cd]$', '\~$', '\.swo$', '\.swp$', '^\.git$', '^\.hg$', '^\.svn$', '\.bzr$']
let NERDTreeChDirMode=0
let NERDTreeQuitOnOpen=1
let NERDTreeMouseMode=2
let NERDTreeShowHidden=1
let NERDTreeKeepTreeInNewTab=1
let g:nerdtree_tabs_open_on_gui_startup=0
endif
" }
" Tabularize {
if isdirectory(expand("~/.vim/bundle/tabular"))
nmap <Leader>a& :Tabularize /&<CR>
vmap <Leader>a& :Tabularize /&<CR>
nmap <Leader>a= :Tabularize /^[^=]*\zs=<CR>
vmap <Leader>a= :Tabularize /^[^=]*\zs=<CR>
nmap <Leader>a=> :Tabularize /=><CR>
vmap <Leader>a=> :Tabularize /=><CR>
nmap <Leader>a: :Tabularize /:<CR>
vmap <Leader>a: :Tabularize /:<CR>
nmap <Leader>a:: :Tabularize /:\zs<CR>
vmap <Leader>a:: :Tabularize /:\zs<CR>
nmap <Leader>a, :Tabularize /,<CR>
vmap <Leader>a, :Tabularize /,<CR>
nmap <Leader>a,, :Tabularize /,\zs<CR>
vmap <Leader>a,, :Tabularize /,\zs<CR>
nmap <Leader>a<Bar> :Tabularize /<Bar><CR>
vmap <Leader>a<Bar> :Tabularize /<Bar><CR>
endif
" }
" Session List {
set sessionoptions=blank,buffers,curdir,folds,tabpages,winsize
if isdirectory(expand("~/.vim/bundle/sessionman.vim/"))
nmap <leader>sl :SessionList<CR>
nmap <leader>ss :SessionSave<CR>
nmap <leader>sc :SessionClose<CR>
endif
" }
" JSON {
nmap <leader>jt <Esc>:%!python -m json.tool<CR><Esc>:set filetype=json<CR>
let g:vim_json_syntax_conceal = 0
" }
" PyMode {
" Disable if python support not present
if !has('python') && !has('python3')
let g:pymode = 0
endif
if isdirectory(expand("~/.vim/bundle/python-mode"))
let g:pymode_lint_checkers = ['pyflakes']
let g:pymode_trim_whitespaces = 0
let g:pymode_options = 0
let g:pymode_rope = 0
endif
" }
" ctrlp {
if isdirectory(expand("~/.vim/bundle/ctrlp.vim/"))
let g:ctrlp_working_path_mode = 'ra'
nnoremap <silent> <D-t> :CtrlP<CR>
nnoremap <silent> <D-r> :CtrlPMRU<CR>
let g:ctrlp_custom_ignore = {
\ 'dir': '\.git$\|\.hg$\|\.svn$',
\ 'file': '\.exe$\|\.so$\|\.dll$\|\.pyc$' }
if executable('ag')
let s:ctrlp_fallback = 'ag %s --nocolor -l -g ""'
elseif executable('ack-grep')
let s:ctrlp_fallback = 'ack-grep %s --nocolor -f'
elseif executable('ack')
let s:ctrlp_fallback = 'ack %s --nocolor -f'
" On Windows use "dir" as fallback command.
elseif WINDOWS()
let s:ctrlp_fallback = 'dir %s /-n /b /s /a-d'
else
let s:ctrlp_fallback = 'find %s -type f'
endif
if exists("g:ctrlp_user_command")
unlet g:ctrlp_user_command
endif
let g:ctrlp_user_command = {
\ 'types': {
\ 1: ['.git', 'cd %s && git ls-files . --cached --exclude-standard --others'],
\ 2: ['.hg', 'hg --cwd %s locate -I .'],
\ },
\ 'fallback': s:ctrlp_fallback
\ }
if isdirectory(expand("~/.vim/bundle/ctrlp-funky/"))
" CtrlP extensions
let g:ctrlp_extensions = ['funky']
"funky
nnoremap <Leader>fu :CtrlPFunky<Cr>
endif
endif
"}
" TagBar {
if isdirectory(expand("~/.vim/bundle/tagbar/"))
nnoremap <silent> <leader>tt :TagbarToggle<CR>
endif
"}
" Rainbow {
if isdirectory(expand("~/.vim/bundle/rainbow/"))
let g:rainbow_active = 1 "0 if you want to enable it later via :RainbowToggle
endif
"}
" Fugitive {
if isdirectory(expand("~/.vim/bundle/vim-fugitive/"))
nnoremap <silent> <leader>gs :Gstatus<CR>
nnoremap <silent> <leader>gd :Gdiff<CR>
nnoremap <silent> <leader>gc :Gcommit<CR>
nnoremap <silent> <leader>gb :Gblame<CR>
nnoremap <silent> <leader>gl :Glog<CR>
nnoremap <silent> <leader>gp :Git push<CR>
nnoremap <silent> <leader>gr :Gread<CR>
nnoremap <silent> <leader>gw :Gwrite<CR>
nnoremap <silent> <leader>ge :Gedit<CR>
" Mnemonic _i_nteractive
nnoremap <silent> <leader>gi :Git add -p %<CR>
nnoremap <silent> <leader>gg :SignifyToggle<CR>
endif
"}
" YouCompleteMe {
if count(g:spf13_bundle_groups, 'youcompleteme')
let g:acp_enableAtStartup = 0
" enable completion from tags
let g:ycm_collect_identifiers_from_tags_files = 1
" remap Ultisnips for compatibility for YCM
let g:UltiSnipsExpandTrigger = '<C-j>'
let g:UltiSnipsJumpForwardTrigger = '<C-j>'
let g:UltiSnipsJumpBackwardTrigger = '<C-k>'
" Enable omni completion.
autocmd FileType css setlocal omnifunc=csscomplete#CompleteCSS
autocmd FileType html,markdown setlocal omnifunc=htmlcomplete#CompleteTags
autocmd FileType javascript setlocal omnifunc=javascriptcomplete#CompleteJS
autocmd FileType python setlocal omnifunc=pythoncomplete#Complete
autocmd FileType xml setlocal omnifunc=xmlcomplete#CompleteTags
autocmd FileType ruby setlocal omnifunc=rubycomplete#Complete
autocmd FileType haskell setlocal omnifunc=necoghc#omnifunc
" Haskell post write lint and check with ghcmod
" $ `cabal install ghcmod` if missing and ensure
" ~/.cabal/bin is in your $PATH.
if !executable("ghcmod")
autocmd BufWritePost *.hs GhcModCheckAndLintAsync
endif
" For snippet_complete marker.
if !exists("g:spf13_no_conceal")
if has('conceal')
set conceallevel=2 concealcursor=i
endif
endif
" Disable the neosnippet preview candidate window
" When enabled, there can be too much visual noise
" especially when splits are used.
set completeopt-=preview
endif
" }
" neocomplete {
if count(g:spf13_bundle_groups, 'neocomplete')
let g:acp_enableAtStartup = 0
let g:neocomplete#enable_at_startup = 1
let g:neocomplete#enable_smart_case = 1
let g:neocomplete#enable_auto_delimiter = 1
let g:neocomplete#max_list = 15
let g:neocomplete#force_overwrite_completefunc = 1
" Define dictionary.
let g:neocomplete#sources#dictionary#dictionaries = {
\ 'default' : '',
\ 'vimshell' : $HOME.'/.vimshell_hist',
\ '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 {
" These two lines conflict with the default digraph mapping of <C-K>
if !exists('g:spf13_no_neosnippet_expand')
imap <C-k> <Plug>(neosnippet_expand_or_jump)
smap <C-k> <Plug>(neosnippet_expand_or_jump)
endif
if exists('g:spf13_noninvasive_completion')
inoremap <CR> <CR>
" <ESC> takes you out of insert mode
inoremap <expr> <Esc> pumvisible() ? "\<C-y>\<Esc>" : "\<Esc>"
" <CR> accepts first, then sends the <CR>
inoremap <expr> <CR> pumvisible() ? "\<C-y>\<CR>" : "\<CR>"
" <Down> and <Up> cycle like <Tab> and <S-Tab>
inoremap <expr> <Down> pumvisible() ? "\<C-n>" : "\<Down>"
inoremap <expr> <Up> pumvisible() ? "\<C-p>" : "\<Up>"
" Jump up and down the list
inoremap <expr> <C-d> pumvisible() ? "\<PageDown>\<C-p>\<C-n>" : "\<C-d>"
inoremap <expr> <C-u> pumvisible() ? "\<PageUp>\<C-p>\<C-n>" : "\<C-u>"
else
" <C-k> Complete Snippet
" <C-k> Jump to next snippet point
imap <silent><expr><C-k> neosnippet#expandable() ?
\ "\<Plug>(neosnippet_expand_or_jump)" : (pumvisible() ?
\ "\<C-e>" : "\<Plug>(neosnippet_expand_or_jump)")
smap <TAB> <Right><Plug>(neosnippet_jump_or_expand)
inoremap <expr><C-g> neocomplete#undo_completion()
inoremap <expr><C-l> neocomplete#complete_common_string()
"inoremap <expr><CR> neocomplete#complete_common_string()
" <CR>: close popup
" <s-CR>: close popup and save indent.
inoremap <expr><s-CR> pumvisible() ? neocomplete#smart_close_popup()."\<CR>" : "\<CR>"
function! CleverCr()
if pumvisible()
if neosnippet#expandable()
let exp = "\<Plug>(neosnippet_expand)"
return exp . neocomplete#smart_close_popup()
else
return neocomplete#smart_close_popup()
endif
else
return "\<CR>"
endif
endfunction
" <CR> close popup and save indent or expand snippet
imap <expr> <CR> CleverCr()
" <C-h>, <BS>: close popup and delete backword char.
inoremap <expr><BS> neocomplete#smart_close_popup()."\<C-h>"
inoremap <expr><C-y> neocomplete#smart_close_popup()
endif
" <TAB>: completion.
inoremap <expr><TAB> pumvisible() ? "\<C-n>" : "\<TAB>"
inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<TAB>"
" Courtesy of Matteo Cavalleri
function! CleverTab()
if pumvisible()
return "\<C-n>"
endif
let substr = strpart(getline('.'), 0, col('.') - 1)
let substr = matchstr(substr, '[^ \t]*$')
if strlen(substr) == 0
" nothing to match on empty string
return "\<Tab>"
else
" existing text matching
if neosnippet#expandable_or_jumpable()
return "\<Plug>(neosnippet_expand_or_jump)"
else
return neocomplete#start_manual_complete()
endif
endif
endfunction
imap <expr> <Tab> CleverTab()
" }
" Enable heavy omni completion.
if !exists('g:neocomplete#sources#omni#input_patterns')
let g:neocomplete#sources#omni#input_patterns = {}
endif
let g:neocomplete#sources#omni#input_patterns.php = '[^. \t]->\h\w*\|\h\w*::'
let g:neocomplete#sources#omni#input_patterns.perl = '\h\w*->\h\w*\|\h\w*::'
let g:neocomplete#sources#omni#input_patterns.c = '[^.[:digit:] *\t]\%(\.\|->\)'
let g:neocomplete#sources#omni#input_patterns.cpp = '[^.[:digit:] *\t]\%(\.\|->\)\|\h\w*::'
let g:neocomplete#sources#omni#input_patterns.ruby = '[^. *\t]\.\h\w*\|\h\w*::'
" }
" neocomplcache {
elseif count(g:spf13_bundle_groups, 'neocomplcache')
let g:acp_enableAtStartup = 0
let g:neocomplcache_enable_at_startup = 1
let g:neocomplcache_enable_camel_case_completion = 1
let g:neocomplcache_enable_smart_case = 1
let g:neocomplcache_enable_underbar_completion = 1
let g:neocomplcache_enable_auto_delimiter = 1
let g:neocomplcache_max_list = 15
let g:neocomplcache_force_overwrite_completefunc = 1
" Define dictionary.
let g:neocomplcache_dictionary_filetype_lists = {
\ 'default' : '',
\ 'vimshell' : $HOME.'/.vimshell_hist',
\ 'scheme' : $HOME.'/.gosh_completions'
\ }
" Define keyword.
if !exists('g:neocomplcache_keyword_patterns')
let g:neocomplcache_keyword_patterns = {}
endif
let g:neocomplcache_keyword_patterns._ = '\h\w*'
" Plugin key-mappings {
" These two lines conflict with the default digraph mapping of <C-K>
imap <C-k> <Plug>(neosnippet_expand_or_jump)
smap <C-k> <Plug>(neosnippet_expand_or_jump)
if exists('g:spf13_noninvasive_completion')
inoremap <CR> <CR>
" <ESC> takes you out of insert mode
inoremap <expr> <Esc> pumvisible() ? "\<C-y>\<Esc>" : "\<Esc>"
" <CR> accepts first, then sends the <CR>
inoremap <expr> <CR> pumvisible() ? "\<C-y>\<CR>" : "\<CR>"
" <Down> and <Up> cycle like <Tab> and <S-Tab>
inoremap <expr> <Down> pumvisible() ? "\<C-n>" : "\<Down>"
inoremap <expr> <Up> pumvisible() ? "\<C-p>" : "\<Up>"
" Jump up and down the list
inoremap <expr> <C-d> pumvisible() ? "\<PageDown>\<C-p>\<C-n>" : "\<C-d>"
inoremap <expr> <C-u> pumvisible() ? "\<PageUp>\<C-p>\<C-n>" : "\<C-u>"
else
imap <silent><expr><C-k> neosnippet#expandable() ?
\ "\<Plug>(neosnippet_expand_or_jump)" : (pumvisible() ?
\ "\<C-e>" : "\<Plug>(neosnippet_expand_or_jump)")
smap <TAB> <Right><Plug>(neosnippet_jump_or_expand)
inoremap <expr><C-g> neocomplcache#undo_completion()
inoremap <expr><C-l> neocomplcache#complete_common_string()
"inoremap <expr><CR> neocomplcache#complete_common_string()
function! CleverCr()
if pumvisible()
if neosnippet#expandable()
let exp = "\<Plug>(neosnippet_expand)"
return exp . neocomplcache#close_popup()
else
return neocomplcache#close_popup()
endif
else
return "\<CR>"
endif
endfunction
" <CR> close popup and save indent or expand snippet
imap <expr> <CR> CleverCr()
" <CR>: close popup
" <s-CR>: close popup and save indent.
inoremap <expr><s-CR> pumvisible() ? neocomplcache#close_popup()."\<CR>" : "\<CR>"
"inoremap <expr><CR> pumvisible() ? neocomplcache#close_popup() : "\<CR>"
" <C-h>, <BS>: close popup and delete backword char.
inoremap <expr><BS> neocomplcache#smart_close_popup()."\<C-h>"
inoremap <expr><C-y> neocomplcache#close_popup()
endif
" <TAB>: completion.
inoremap <expr><TAB> pumvisible() ? "\<C-n>" : "\<TAB>"
inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<TAB>"
" }
" Enable omni completion.
autocmd FileType css setlocal omnifunc=csscomplete#CompleteCSS
autocmd FileType html,markdown setlocal omnifunc=htmlcomplete#CompleteTags
autocmd FileType javascript setlocal omnifunc=javascriptcomplete#CompleteJS
autocmd FileType python setlocal omnifunc=pythoncomplete#Complete
autocmd FileType xml setlocal omnifunc=xmlcomplete#CompleteTags
autocmd FileType ruby setlocal omnifunc=rubycomplete#Complete
autocmd FileType haskell setlocal omnifunc=necoghc#omnifunc
" Enable heavy omni completion.
if !exists('g:neocomplcache_omni_patterns')
let g:neocomplcache_omni_patterns = {}
endif
let g:neocomplcache_omni_patterns.php = '[^. \t]->\h\w*\|\h\w*::'
let g:neocomplcache_omni_patterns.perl = '\h\w*->\h\w*\|\h\w*::'
let g:neocomplcache_omni_patterns.c = '[^.[:digit:] *\t]\%(\.\|->\)'
let g:neocomplcache_omni_patterns.cpp = '[^.[:digit:] *\t]\%(\.\|->\)\|\h\w*::'
let g:neocomplcache_omni_patterns.ruby = '[^. *\t]\.\h\w*\|\h\w*::'
let g:neocomplcache_omni_patterns.go = '\h\w*\.\?'
" }
" Normal Vim omni-completion {
" To disable omni complete, add the following to your .vimrc.before.local file:
" let g:spf13_no_omni_complete = 1
elseif !exists('g:spf13_no_omni_complete')
" Enable omni-completion.
autocmd FileType css setlocal omnifunc=csscomplete#CompleteCSS
autocmd FileType html,markdown setlocal omnifunc=htmlcomplete#CompleteTags
autocmd FileType javascript setlocal omnifunc=javascriptcomplete#CompleteJS
autocmd FileType python setlocal omnifunc=pythoncomplete#Complete
autocmd FileType xml setlocal omnifunc=xmlcomplete#CompleteTags
autocmd FileType ruby setlocal omnifunc=rubycomplete#Complete
autocmd FileType haskell setlocal omnifunc=necoghc#omnifunc
endif
" }
" Snippets {
if count(g:spf13_bundle_groups, 'neocomplcache') ||
\ count(g:spf13_bundle_groups, 'neocomplete')
" Use honza's snippets.
let g:neosnippet#snippets_directory='~/.vim/bundle/vim-snippets/snippets'
" Enable neosnippet snipmate compatibility mode
let g:neosnippet#enable_snipmate_compatibility = 1
" For snippet_complete marker.
if !exists("g:spf13_no_conceal")
if has('conceal')
set conceallevel=2 concealcursor=i
endif
endif
" Enable neosnippets when using go
let g:go_snippet_engine = "neosnippet"
" Disable the neosnippet preview candidate window
" When enabled, there can be too much visual noise
" especially when splits are used.
set completeopt-=preview
endif
" }
" FIXME: Isn't this for Syntastic to handle?
" Haskell post write lint and check with ghcmod
" $ `cabal install ghcmod` if missing and ensure
" ~/.cabal/bin is in your $PATH.
if !executable("ghcmod")
autocmd BufWritePost *.hs GhcModCheckAndLintAsync
endif
" UndoTree {
if isdirectory(expand("~/.vim/bundle/undotree/"))
nnoremap <Leader>u :UndotreeToggle<CR>
" If undotree is opened, it is likely one wants to interact with it.
let g:undotree_SetFocusWhenToggle=1
endif
" }
" indent_guides {
if isdirectory(expand("~/.vim/bundle/vim-indent-guides/"))
let g:indent_guides_start_level = 2
let g:indent_guides_guide_size = 1
let g:indent_guides_enable_on_vim_startup = 1
endif
" }
" Wildfire {
let g:wildfire_objects = {
\ "*" : ["i'", 'i"', "i)", "i]", "i}", "ip"],
\ "html,xml" : ["at"],
\ }
" }
" vim-airline {
" Set configuration options for the statusline plugin vim-airline.
" Use the powerline theme and optionally enable powerline symbols.
" To use the symbols , , , , , , and .in the statusline
" segments add the following to your .vimrc.before.local file:
" let g:airline_powerline_fonts=1
" If the previous symbols do not render for you then install a
" powerline enabled font.
" See `:echo g:airline_theme_map` for some more choices
" Default in terminal vim is 'dark'
if isdirectory(expand("~/.vim/bundle/vim-airline-themes/"))
if !exists('g:airline_theme')
let g:airline_theme = 'solarized'
endif
if !exists('g:airline_powerline_fonts')
" Use the default set of separators with a few customizations
let g:airline_left_sep='›' " Slightly fancier than '>'
let g:airline_right_sep='‹' " Slightly fancier than '<'
endif
endif
" }
" }
" GUI Settings {
" GVIM- (here instead of .gvimrc)
if has('gui_running')
set guioptions-=T " Remove the toolbar
set lines=40 " 40 lines of text instead of 24
if !exists("g:spf13_no_big_font")
if LINUX() && has("gui_running")
set guifont=Andale\ Mono\ Regular\ 12,Menlo\ Regular\ 11,Consolas\ Regular\ 12,Courier\ New\ Regular\ 14
elseif OSX() && has("gui_running")
set guifont=Andale\ Mono\ Regular:h12,Menlo\ Regular:h11,Consolas\ Regular:h12,Courier\ New\ Regular:h14
elseif WINDOWS() && has("gui_running")
set guifont=Andale_Mono:h10,Menlo:h10,Consolas:h10,Courier_New:h10
endif
endif
else
if &term == 'xterm' || &term == 'screen'
set t_Co=256 " Enable 256 colors to stop the CSApprox warning and make xterm vim shine
endif
"set term=builtin_ansi " Make arrow and other keys work
endif
" }
" Functions {
" Initialize directories {
function! InitializeDirectories()
let parent = $HOME
let prefix = 'vim'
let dir_list = {
\ 'backup': 'backupdir',
\ 'views': 'viewdir',
\ 'swap': 'directory' }
if has('persistent_undo')
let dir_list['undo'] = 'undodir'
endif
" To specify a different directory in which to place the vimbackup,
" vimviews, vimundo, and vimswap files/directories, add the following to
" your .vimrc.before.local file:
" let g:spf13_consolidated_directory = <full path to desired directory>
" eg: let g:spf13_consolidated_directory = $HOME . '/.vim/'
if exists('g:spf13_consolidated_directory')
let common_dir = g:spf13_consolidated_directory . prefix
else
let common_dir = parent . '/.' . prefix
endif
for [dirname, settingname] in items(dir_list)
let directory = common_dir . dirname . '/'
if exists("*mkdir")
if !isdirectory(directory)
call mkdir(directory)
endif
endif
if !isdirectory(directory)
echo "Warning: Unable to create backup directory: " . directory
echo "Try: mkdir -p " . directory
else
let directory = substitute(directory, " ", "\\\\ ", "g")
exec "set " . settingname . "=" . directory
endif
endfor
endfunction
call InitializeDirectories()
" }
" Initialize NERDTree as needed {
function! NERDTreeInitAsNeeded()
redir => bufoutput
buffers!
redir END
let idx = stridx(bufoutput, "NERD_tree")
if idx > -1
NERDTreeMirror
NERDTreeFind
wincmd l
endif
endfunction
" }
" Strip whitespace {
function! StripTrailingWhitespace()
" Preparation: save last search, and cursor position.
let _s=@/
let l = line(".")
let c = col(".")
" do the business:
%s/\s\+$//e
" clean up: restore previous search history, and cursor position
let @/=_s
call cursor(l, c)
endfunction
" }
" Shell command {
function! s:RunShellCommand(cmdline)
botright new
setlocal buftype=nofile
setlocal bufhidden=delete
setlocal nobuflisted
setlocal noswapfile
setlocal nowrap
setlocal filetype=shell
setlocal syntax=shell
call setline(1, a:cmdline)
call setline(2, substitute(a:cmdline, '.', '=', 'g'))
execute 'silent $read !' . escape(a:cmdline, '%#')
setlocal nomodifiable
1
endfunction
command! -complete=file -nargs=+ Shell call s:RunShellCommand(<q-args>)
" e.g. Grep current file for <search_term>: Shell grep -Hn <search_term> %
" }
function! s:IsSpf13Fork()
let s:is_fork = 0
let s:fork_files = ["~/.vimrc.fork", "~/.vimrc.before.fork", "~/.vimrc.bundles.fork"]
for fork_file in s:fork_files
if filereadable(expand(fork_file, ":p"))
let s:is_fork = 1
break
endif
endfor
return s:is_fork
endfunction
function! s:ExpandFilenameAndExecute(command, file)
execute a:command . " " . expand(a:file, ":p")
endfunction
function! s:EditSpf13Config()
call <SID>ExpandFilenameAndExecute("tabedit", "~/.vimrc")
call <SID>ExpandFilenameAndExecute("vsplit", "~/.vimrc.before")
call <SID>ExpandFilenameAndExecute("vsplit", "~/.vimrc.bundles")
execute bufwinnr(".vimrc") . "wincmd w"
call <SID>ExpandFilenameAndExecute("split", "~/.vimrc.local")
wincmd l
call <SID>ExpandFilenameAndExecute("split", "~/.vimrc.before.local")
wincmd l
call <SID>ExpandFilenameAndExecute("split", "~/.vimrc.bundles.local")
if <SID>IsSpf13Fork()
execute bufwinnr(".vimrc") . "wincmd w"
call <SID>ExpandFilenameAndExecute("split", "~/.vimrc.fork")
wincmd l
call <SID>ExpandFilenameAndExecute("split", "~/.vimrc.before.fork")
wincmd l
call <SID>ExpandFilenameAndExecute("split", "~/.vimrc.bundles.fork")
endif
execute bufwinnr(".vimrc.local") . "wincmd w"
endfunction
execute "noremap " . s:spf13_edit_config_mapping " :call <SID>EditSpf13Config()<CR>"
execute "noremap " . s:spf13_apply_config_mapping . " :source ~/.vimrc<CR>"
" }
" Use fork vimrc if available {
if filereadable(expand("~/.vimrc.fork"))
source ~/.vimrc.fork
endif
" }
" Use local vimrc if available {
if filereadable(expand("~/.vimrc.local"))
source ~/.vimrc.local
endif
" }
" Use local gvimrc if available and gui is running {
if has('gui_running')
if filereadable(expand("~/.gvimrc.local"))
source ~/.gvimrc.local
endif
endif
" }
Plugin 'morhetz/gruvbox'
set bg=dark
colorscheme gruvbox
Plugin 'morhetz/gruvbox'
set bg=dark
colorscheme gruvbox
"设置相对行号
set relativenumber
Plugin 'Valloric/YouCompleteMe'
let g:ycm_global_ycm_extra_conf = '~/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp/ycm/.ycm_extra_conf.py'
Plugin 'iamcco/markdown-preview.vim'
Plugin 'airblade/vim-gitgutter'
exec 'cd ' . fnameescape('/Users/itgoyo/Documents/Vim')
set rtp+=/usr/local/opt/fzf
"Plugin '/usr/local/opt/fzf'
set rtp+=/home/itgoyo/.fzf/
Plugin 'junegunn/fzf.vim'
" 切换buffer
"nnoremap <silent> [b :bprevious<CR>
"nnoremap <silent> [n :bnext<CR>
nnoremap <silent> [b :bprevious<CR>
nnoremap <silent> ]b :bnext<CR>
nnoremap <silent> [B :bfirst<CR>
nnoremap <silent> ]B :blast<CR>
" use ctrl+hjkl switch window
" nnoremap <C-l> <C-w>l 这种用法没效果因为已经被方向快捷键拦截了
nnoremap <leader>h <C-w>h
nnoremap <leader>j <C-w>j
nnoremap <leader>k <C-w>k
nnoremap <leader>l <C-w>l
"使用leader+w 直接保存
"inoremap <leader>w <Esc>:w<cr>
"noremap <leader>w :w<cr>
:noremap <D-S> :w<cr>
noremap <leader>s :w<cr>
":noremap <leader>s :w<cr>
:noremap <leader>p :MarkdownPreview<cr>
"解决insert模式切换回normal模式下延迟的问题
set timeoutlen=1 ttimeoutlen=0
"Mode Settings
let &t_SI.="\e[5 q" "SI = INSERT mode
let &t_SR.="\e[4 q" "SR = REPLACE mode
let &t_EI.="\e[1 q" "EI = NORMAL mode (ELSE)
"Cursor settings:
" 1 -> blinking block
" 2 -> solid block
" 3 -> blinking underscore
" 4 -> solid underscore
" 5 -> blinking vertical bar
" 6 -> solid vertical bar
"let &t_SI = "\<Esc>]50;CursorShape=1\x7"
"let &t_SR = "\<Esc>]50;CursorShape=2\x7"
"let &t_EI = "\<Esc>]50;CursorShape=0\x7"
" vim-go
Plugin 'fatih/vim-go'
" EasyMotion
" <Leader>f{char} to move to {char}
map <Leader>f <Plug>(easymotion-bd-f)
nmap <Leader>f <Plug>(easymotion-overwin-f)
" s{char}{char} to move to {char}{char}
nmap s <Plug>(easymotion-overwin-f2)
" Move to line
map <Leader>L <Plug>(easymotion-bd-jk)
nmap <Leader>L <Plug>(easymotion-overwin-line)
" Move to word
map <Leader>w <Plug>(easymotion-bd-w)
nmap <Leader>w <Plug>(easymotion-overwin-w)
Vim
详细Vim快捷键大全
Vim的配置以spf-13为例子
项目地址: https://github.com/spf13/spf13-vim
Vim的安装
The easiest way to install spf13-vim is to use our automatic installer by simply copying and pasting the following line into a terminal. This will install spf13-vim and backup your existing vim configuration. If you are upgrading from a prior version (before 3.0) this is also the recommended installation.
Requires Git 1.7+ and Vim 7.3+
If you have a bash-compatible shell you can run the script directly:
此过程会比较长,包括插件的下载还有安装,这个过程将近1个多小时
On Windows and *nix Git and Curl are required. Also, if you haven't done so already, you'll need to install Vim. The quickest option to install all three dependencies (Git, Curl, Vim and spf13-vim) is via Chocolatey NuGet. After installing Chocolatey, execute the following commands on the command prompt:
Install with cmd.exe(run as admin mode)
一直Y,整个过程大概2h左右
Vim插件的介绍
Vundle(The best plugin manager)
Vundle is an excellent system built on the same principles as Pathogen, but with an integrated plugin management system that is Git and Github aware.
spf13-vim uses the Vundle plugin management system to have a well organized vim directory (Similar to mac's app folders). Vundle also ensures that the latest versions of your plugins are installed and makes it easy to keep them up to date.
NERDTree(file navigation)
NERDTree is a file explorer plugin that provides "project drawer" functionality to your vim editing. You can learn more about it with :help NERDTree or checkout my post on NERDTree.
Use
Ctrl+e
to toggle NERDTreectrlp(fast file finder)
Ctrlp replaces the Command-T plugin with a 100% viml plugin. It provides an intuitive and fast mechanism to load files from the file system (with regex and fuzzy find), from open buffers, and from recently used files.
Use
Ctrl+p
to toggle Ctrlpneocomplcache(autocomplete++)
NeoComplCache is an amazing autocomplete plugin with additional support for snippets. It can complete simulatiously from the dictionary, buffer, omnicomplete and snippets. This is the one true plugin that brings Vim autocomplete on par with the best editors.
Use
Ctrl+n
to toggle neocomplcacheTagbar(tag generation and navigation)
spf13-vim includes the Tagbar plugin. This plugin requires exuberant-ctags and will automatically generate tags for your open files. It also provides a panel to navigate easily via tags
Use
,tt
to toggle neocomplcache关于在Mac端ctags无效的解决方法
https://brew.sh/
https://github.com/universal-ctags/ctags
https://github.com/universal-ctags/homebrew-universal-ctags
在Windows端,如果想切换到别的盘符进行操作的话,使用
:NERDTree D:\\
进行目录的跳转
Preview: To preview markdown format you need to install bluecloth gem
在使用previewMarkdown的时候出现了
Preview: To preview markdown format you need to install bluecloth gem
解决方法:
sudo gem install redcarpet
sudo gem install bluecloth
Linux出现的问题
can't find header files for ruby at /usr/lib/ruby/include/ruby.h
解决方法:sudo apt-get install ruby-dev
提示找不到tag文件
窗口切换快捷键
Ctrl+w+w
关闭分屏
打开多个窗口了之后,怎么快速切换
:buffers 列表 :bn下一个 :bp 上一个 :b17
取消查找遗留的边框
VIM编辑多行
全局搜索Ack
windows
在Windows下安装它们可以使用Chocolatey,安装方法如下:首先以管理员权限打开cmd窗口,然后运行下列命令,首先以管理员权限打开cmd窗口(管理员那个终端才有效),然后运行下列命令
安装完了之后
Mac
如果出现一下乱码
下载安装ActivePerl,配置环境变量即可解决此问题。 下载地址
SpaceVim
该配色使用的是
gruvbox
如果想更换成此主题
let g:airline_theme = 'dark'
vim --version | grep "clipboard"
sudo apt-get install vim-gnome
vim --version | grep "clipboard"
let g:EasyMotion_smartcase = 1 "let g:EasyMotion_startofline = 0 " keep cursor colum when JK motion maph (easymotion-linebackward)
map j (easymotion-j)
map k (easymotion-k)
map l (easymotion-lineforward)
" 重复上一次操作, 类似repeat插件, 很强大
map . (easymotion-repeat)
使用:
1、 \cc 注释当前行和选中行
2、 \cn 没有发现和\cc有区别
3、 \c<空格> 如果被选区域有部分被注释,则对被选区域执行取消注释操作,其它情况执行反转注释操作
4、 \cm 对被选区域用一对注释符进行注释,前面的注释对每一行都会添加注释
5、 \ci 执行反转注释操作,选中区域注释部分取消注释,非注释部分添加注释
6、 \cs 添加性感的注释,代码开头介绍部分通常使用该注释
7、 \cy 添加注释,并复制被添加注释的部分
8、 \c$ 注释当前光标到改行结尾的内容
9、 \cA 跳转到该行结尾添加注释,并进入编辑模式
10、\ca 转换注释的方式,比如: //和//
11、\cl \cb 左对齐和左右对其,左右对其主要针对//
12、\cu 取消注释
方案一:
brew install vim --with-lua
方案二:
brew uninstall vim brew install luajit brew install vim --with-luajit
nmap "+gp
nmap "+y