ultimate vimrc

Upload: dhaakchik

Post on 02-Jun-2018

219 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/10/2019 ultimate vimrc

    1/21

    " Modeline and Notes {" vim: set sw=4 ts=4 sts=4 et tw=78 foldmarker={,} foldlevel=0 foldmethod=markerspell:"" __ _ _____ _" ___ _ __ / _/ |___ / __ __(_)_ __ ___" / __| '_ \| |_| | |_ \ _____\ \ / /| | '_ ` _ \" \__ \ |_) | _| |___) |_____|\ 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('win16') || 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

  • 8/10/2019 ultimate vimrc

    2/21

    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 " 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

  • 8/10/2019 ultimate vimrc

    3/21

    " 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("'\"")

  • 8/10/2019 ultimate vimrc

    4/21

    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 linenumber

    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=%

  • 8/10/2019 ultimate vimrc

    5/21

    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= " 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 autocmd BufWritePre if !exists('g:spf13_keep_trailing_whitespace') | call StripTrailingWhitespace() | endif "autocmd FileType go autocmd BufWritePre 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

    " Easier moving in tabs and windows

    " The lines conflict with the default digraph mapping of " 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 j_ map k_ map l_ map h_ endif

  • 8/10/2019 ultimate vimrc

    6/21

    " 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("$") noremap :call WrapRelativeMotion("$") noremap 0 :call WrapRelativeMotion("0") noremap :call WrapRelativeMotion("0") noremap ^ :call WrapRelativeMotion("^") " Overwrite the operator pending $/ mappings from above " to force inclusive motion with :execute normal! onoremap $ v:call WrapRelativeMotion("$") onoremap v:call WrapRelativeMotion("$") " Overwrite the Visual+select mode mappings from above " to ensure the correct vis_sel flag is passed to function

    vnoremap $ :call WrapRelativeMotion("$", 1) vnoremap :call WrapRelativeMotion("$", 1) vnoremap 0 :call WrapRelativeMotion("0", 1) vnoremap :call WrapRelativeMotion("0", 1) vnoremap ^ :call WrapRelativeMotion("^", 1) 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 gT map gt endif

    " Stupid shift key fixes if !exists('g:spf13_no_keyfixes') if has("user_commands") command! -bang -nargs=* -complete=file E e command! -bang -nargs=* -complete=file W w command! -bang -nargs=* -complete=file Wq wq

  • 8/10/2019 ultimate vimrc

    7/21

    command! -bang -nargs=* -complete=file WQ wq command! -bang Wa wa command! -bang WA wa command! -bang Q q command! -bang QA qa command! -bang Qa qa 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 f0 :set foldlevel=0 nmap f1 :set foldlevel=1 nmap f2 :set foldlevel=2 nmap f3 :set foldlevel=3 nmap f4 :set foldlevel=4 nmap f5 :set foldlevel=5 nmap f6 :set foldlevel=6 nmap f7 :set foldlevel=7

    nmap f8 :set foldlevel=8 nmap f9 :set foldlevel=9

    " 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 / :nohlsearch else nmap / :set invhlsearch endif

    " Find merge conflict markers map fc /\v^[]{7}( .*\|$)

    " 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

    " Allow using the repeat operator with a visual selection (!) " http://stackoverflow.com/a/8064607/127816 vnoremap . :normal .

    " 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 %% =expand('%:h').'/'

  • 8/10/2019 ultimate vimrc

    8/21

    map ew :e %% map es :sp %% map ev :vsp %% map et :tabe %%

    " Adjust viewports to the same size map = =

    " Map ff to display all lines with keyword under cursor " and ask which one to jump to nmap ff [I:let nr = input("Which one: ")exe "normal " . nr ."[\t"

    " Easier horizontal scrolling map zl zL map zh zH

    " Easier formatting nnoremap q gwip

    " FIXME: Revert this f70be548 " fullscreen mode for GVIM and Terminal, need 'wmctrl' in you PATH map :call system("wmctrl -ir " . v:windowid . " -b toggle,fullscreen")

    " }

    " Plugins {

    " 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"))

  • 8/10/2019 ultimate vimrc

    9/21

    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=darkcyanctermbg=lightgray cterm=NONE hi PmenuThumb guifg=#F8F8F8 guibg=#8A95A7 gui=NONE ctermfg=lightgra

    y ctermbg=darkcyan cterm=NONE

    " Some convenient mappings inoremap pumvisible() ? "\" : "\" if exists('g:spf13_map_cr_omni_complete') inoremap pumvisible() ? "\" : "\" endif inoremap pumvisible() ? "\" : "\" inoremap pumvisible() ? "\" : "\" inoremap pumvisible() ? "\\\": "\" inoremap pumvisible() ? "\\\" :"\"

    " 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

  • 8/10/2019 ultimate vimrc

    10/21

  • 8/10/2019 ultimate vimrc

    11/21

    let g:vim_json_syntax_conceal = 0 " }

    " PyMode { " Disable if python support not present if !has('python') 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 :CtrlP nnoremap :CtrlPMRU let g:ctrlp_custom_ignore = { \ 'dir': '\.git$\|\.hg$\|\.svn$',

    \ 'file': '\.exe$\|\.so$\|\.dll$\|\.pyc$' }

    " On Windows use "dir" as fallback command. if WINDOWS() let s:ctrlp_fallback = 'dir %s /-n /b /s /a-d' elseif 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' else let s:ctrlp_fallback = 'find %s -type f'

    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 fu :CtrlPFunky endif endif "}

    " TagBar { if isdirectory(expand("~/.vim/bundle/tagbar/")) nnoremap tt :TagbarToggle

  • 8/10/2019 ultimate vimrc

    12/21

    " If using go please install the gotags program using the following " go install github.com/jstemmer/gotags " And make sure gotags is in your path let g:tagbar_type_go = { \ 'ctagstype' : 'go', \ 'kinds' : [ 'p:package', 'i:imports:1', 'c:constants', 'v:variables', \ 't:types', 'n:interfaces', 'w:fields', 'e:embedded', 'm:methods', \ 'r:constructor', 'f:functions' ], \ 'sro' : '.', \ 'kind2scope' : { 't' : 'ctype', 'n' : 'ntype' }, \ 'scope2kind' : { 'ctype' : 't', 'ntype' : 'n' }, \ 'ctagsbin' : 'gotags', \ 'ctagsargs' : '-sort -silent' \ } endif "}

    " Fugitive { if isdirectory(expand("~/.vim/bundle/vim-fugitive/")) nnoremap gs :Gstatus

    nnoremap gd :Gdiff nnoremap gc :Gcommit nnoremap gb :Gblame nnoremap gl :Glog nnoremap gp :Git push nnoremap gr :Gread nnoremap gw :Gwrite nnoremap ge :Gedit " Mnemonic _i_nteractive nnoremap gi :Git add -p % nnoremap gg :SignifyToggle 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 = '' let g:UltiSnipsJumpForwardTrigger = '' let g:UltiSnipsJumpBackwardTrigger = ''

    " 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

  • 8/10/2019 ultimate vimrc

    13/21

    " 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 if !exists('g:spf13_no_neosnippet_expand') imap (neosnippet_expand_or_jump)

    smap (neosnippet_expand_or_jump) endif if exists('g:spf13_noninvasive_completion') inoremap " takes you out of insert mode inoremap pumvisible() ? "\\" : "\" " accepts first, then sends the inoremap pumvisible() ? "\\" : "\"

  • 8/10/2019 ultimate vimrc

    14/21

    " and cycle like and inoremap pumvisible() ? "\" : "\" inoremap pumvisible() ? "\" : "\" " Jump up and down the list inoremap pumvisible() ? "\\\" : "\" inoremap pumvisible() ? "\\\" : "\" else " Complete Snippet " Jump to next snippet point imap neosnippet#expandable() ? \ "\(neosnippet_expand_or_jump)" : (pumvisible() ? \ "\" : "\(neosnippet_expand_or_jump)") smap (neosnippet_jump_or_expand)

    inoremap neocomplete#undo_completion() inoremap neocomplete#complete_common_string() "inoremap neocomplete#complete_common_string()

    " : close popup " : close popup and save indent.

    inoremap pumvisible() ? neocomplete#smart_close_popup()"\" : "\"

    function! CleverCr() if pumvisible() if neosnippet#expandable() let exp = "\(neosnippet_expand)" return exp . neocomplete#smart_close_popup() else return neocomplete#smart_close_popup() endif else return "\"

    endif endfunction

    " close popup and save indent or expand snippetimap CleverCr()" , : close popup and delete backword char.

    inoremap neocomplete#smart_close_popup()."\" inoremap neocomplete#smart_close_popup() endif " : completion. inoremap pumvisible() ? "\" : "\" inoremap pumvisible() ? "\" : "\"

    " Courtesy of Matteo Cavalleri

    function! CleverTab() if pumvisible() return "\" endif let substr = strpart(getline('.'), 0, col('.') - 1) let substr = matchstr(substr, '[^ \t]*$') if strlen(substr) == 0 " nothing to match on empty string

  • 8/10/2019 ultimate vimrc

    15/21

    return "\" else " existing text matching if neosnippet#expandable_or_jumpable() return "\(neosnippet_expand_or_jump)" else return neocomplete#start_manual_complete() endif endif endfunction

    imap 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 imap (neosnippet_expand_or_jump) smap (neosnippet_expand_or_jump) if exists('g:spf13_noninvasive_completion') inoremap

  • 8/10/2019 ultimate vimrc

    16/21

    " takes you out of insert mode inoremap pumvisible() ? "\\" : "\" " accepts first, then sends the inoremap pumvisible() ? "\\" : "\" " and cycle like and inoremap pumvisible() ? "\" : "\" inoremap pumvisible() ? "\" : "\" " Jump up and down the list inoremap pumvisible() ? "\\\" : "\" inoremap pumvisible() ? "\\\" : "\" else imap neosnippet#expandable() ? \ "\(neosnippet_expand_or_jump)" : (pumvisible() ? \ "\" : "\(neosnippet_expand_or_jump)") smap (neosnippet_jump_or_expand)

    inoremap neocomplcache#undo_completion() inoremap neocomplcache#complete_common_string()

    "inoremap neocomplcache#complete_common_string()

    function! CleverCr() if pumvisible() if neosnippet#expandable() let exp = "\(neosnippet_expand)" return exp . neocomplcache#close_popup() else return neocomplcache#close_popup() endif else return "\" endif

    endfunction

    " close popup and save indent or expand snippetimap CleverCr()

    " : close popup " : close popup and save indent. inoremap pumvisible() ? neocomplcache#close_popup()"\" : "\" "inoremap pumvisible() ? neocomplcache#close_popup() : "\"

    " , : close popup and delete backword char.

    inoremap neocomplcache#smart_close_popup()."\" inoremap neocomplcache#close_popup() endif " : completion. inoremap pumvisible() ? "\" : "\" inoremap pumvisible() ? "\" : "\" " }

    " Enable omni completion.

  • 8/10/2019 ultimate vimrc

    17/21

  • 8/10/2019 ultimate vimrc

    18/21

  • 8/10/2019 ultimate vimrc

    19/21

    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 = " 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

  • 8/10/2019 ultimate vimrc

    20/21

    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)

  • 8/10/2019 ultimate vimrc

    21/21

    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() " e.g. Grep current file for : Shell grep -Hn % " }

    " }

    " 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" }