" {{{ " Maintainer: Johannes Steudle " .vimrc " for Unix and macOS: ~/.vimrc " }}} " Use Vim defaults (much better!) set nocompatible syntax on " Shell {{{ if $SHELL =~ 'bin/fish' set shell=/bin/sh endif " }}} set hidden " Allow switching edited buffers without saving set title " Show filename " Layout {{{ set cmdheight=2 " Make command line two lines high set laststatus=2 " Always show status line, even for one window set termencoding=utf-8 set encoding=utf-8 " Use UTF-8 as the default buffer encoding " }}} " Indentation {{{ set autoindent " copy indent from current line set smartindent " Set indention set shiftround " shift to nearest indent " }}} " Behavior {{{ set autoread " read open files again when changed outside Vim set ttyfast " Improves redrawing on newer computers set switchbuf=useopen " reveal already opened files from the " quickfix window instead of opening new " buffers set nostartofline " Keep cursor in current column when using page commands set autochdir " automatically set current directory to directory of last opened file set visualbell " Set visual bell instead of acustic set mouse=a " enable the use of the mouse set number relativenumber " hybrid relative numbers set matchtime=4 " Jump to matching bracket for n/10 seconds set nospell set nojoinspaces " Insert only one space when joining lines set magic " Use magic escaping set completeopt=menu,menuone,longest,preview " Insert mode completion options set backspace=indent,eol,start " }}} " Show some invisible characters {{{ set listchars=tab:▸\ ,trail:·,extends:#,nbsp:· set nolist " }}} " Tab settings {{{ set tabstop=4 " Tab size set shiftwidth=4 " Shift width set softtabstop=4 set expandtab " Tabs to spaces set smarttab " }}} " Handle long lines {{{ set wrap set textwidth=79 set formatoptions=qrn1 set colorcolumn=85 set linebreak set display+=lastline " }}} " Search {{{ See http://stevelosh.com/blog/2010/09/coming-home-to-vim/ set hlsearch " Highlight search set incsearch " incremental searching set ignorecase smartcase " Case-insensitive searching set showmatch " When a bracket is inserted, briefly jump to a matching one nnoremap % vnoremap % " }}} " Wildmenu {{{ set wildmenu " Use menu to show command-line completion (in 'full' case) set wildmode=list:longest,full " set command-line completion mode: " - on first , when more than one match, list all matches and complete the longest common string " - on second , complete the next full match and show menu " Ignore these filenames during enhanced command line completion. set wildignore+=*/.idea/*,*/.project/* " ignore IDE project files set wildignore+=*/.git/*,*/.hg/*,*/.svn/* " ignore version control files set wildignore+=*.aux,*.out,*.toc " LaTeX intermediate files set wildignore+=*.jpg,*.bmp,*.gif " binary images set wildignore+=*.luac " Lua byte code set wildignore+=*.o,*.obj,*.exe,*.dll,*.manifest,*.so,*.zip " compiled object files set wildignore+=*.pyc " Python byte code set wildignore+=*.spl " compiled spelling word lists set wildignore+=*.sw? " Vim swap files set wildignore+=.DS_Store " Mac files set wildignore+=*/tmp/* " MacOSX/Linux set wildignore+=*\\tmp\\* " Windows " }}} " Python {{{ let g:python_host_prog = '/usr/local/bin/python' let g:python3_host_prog = '/usr/local/bin/python3' " Temporary workaround for python 3.7: https://github.com/vim/vim/issues/3117#issuecomment-402622616 if has('python3') silent! python3 1 endif " }}} " PlugIn-Configuration {{{ call plug#begin('$HOME/.vim/plugged') " Motion Plug 'chaoren/vim-wordmotion' " Plugins for handling various formats Plug 'plasticboy/vim-markdown', { 'for': 'markdown' } Plug 'itspriddle/vim-marked', { 'for': 'markdown' } " git plugins Plug 'tpope/vim-fugitive' Plug 'airblade/vim-gitgutter' " syntax checker for vim Plug 'w0rp/ale' " syntax plugins Plug 'keith/swift.vim' Plug 'b4winckler/vim-objc' Plug 'darfink/vim-plist' Plug 'aliva/vim-fish' Plug 'mileszs/ack.vim' Plug 'vim-python/python-syntax' Plug 'aklt/plantuml-syntax' Plug 'vim-scripts/Rainbow-Parenthsis-Bundle' Plug 'vim-scripts/confluencewiki.vim' " Add global syntax formatting config capability Plug 'editorconfig/editorconfig-vim' " Auto formatting various files Plug 'sbdchd/neoformat' " Add Theme Plug 'altercation/vim-colors-solarized' Plug 'ryanoasis/vim-devicons' Plug 'sonph/onehalf', { 'rtp': 'vim/' } Plug 'ErichDonGubler/vim-sublime-monokai' " Buffer manager Plug 'jeetsukumaran/vim-buffergator' Plug 'vim-scripts/YankRing.vim' " Nice status bar Plug 'vim-airline/vim-airline' Plug 'vim-airline/vim-airline-themes' " Completion plugins Plug 'Rip-Rip/clang_complete' Plug 'ervandew/supertab' Plug 'prabirshrestha/asyncomplete.vim' Plug 'prabirshrestha/asyncomplete-buffer.vim' Plug 'Raimondi/delimitMate' Plug 'Valloric/YouCompleteMe' " Region expanding Plug 'terryma/vim-expand-region' Plug 'terryma/vim-multiple-cursors' Plug 'tpope/vim-surround' " Use the fancy silver searcher Plug 'rking/ag.vim' " Nice filetree Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' } Plug 'Xuyuanp/nerdtree-git-plugin', { 'on': 'NERDTreeToggle' } " Little file manager Plug 'ctrlpvim/ctrlp.vim' Plug 'tpope/vim-eunuch' " Own plugins Plug 'tweetjay/tweetjay-theme' Plug 'tweetjay/vim-backstate' " Fancy starting screen Plug 'mhinz/vim-startify' call plug#end() " }}} " Colorscheme {{{ if has('gui_running') set background=dark colorscheme onehalfdark elseif &t_Co < 256 colorscheme default set nocursorline " looks bad in this mode else set background=dark let g:solarized_termcolors=256 " instead of 16 color with mapping in terminal colorscheme solarized " customized colors highlight SignColumn ctermbg=234 highlight StatusLine cterm=bold ctermfg=245 ctermbg=235 highlight StatusLineNC cterm=bold ctermfg=245 ctermbg=235 highlight SpellBad cterm=underline endif " highlight current line, but only in active window augroup CursorLineOnlyInActiveWindow autocmd! autocmd VimEnter,WinEnter,BufWinEnter * setlocal cursorline autocmd WinLeave * setlocal nocursorline augroup END " }}} " Configure CTRL-P {{{ let g:ctrlp_custom_ignore = { \ 'dir': '\v[\/]\.(git|hg|svn)$', \ 'file': '\v\.(exe|so|dll)$', \ 'link': 'some_bad_symbolic_links', \ } " }}} " Configure Syntastic {{{ if has('syntastic') set statusline+=%#warningmsg# set statusline+=%{SyntasticStatuslineFlag()} set statusline+=%* let g:syntastic_always_populate_loc_list = 1 let g:syntastic_auto_loc_list = 1 let g:syntastic_check_on_open = 1 let g:syntastic_check_on_wq = 0 let g:syntastic_swift_swiftlint_use_defaults = 1 let g:syntastic_swift_checkers = ['swiftpm', 'swiftlint'] endif " }}} " StatusLine {{{ configure airline status bar let g:airline#extensions#tabline#enabled = 1 let g:airline_powerline_fonts = 1 let g:airline_theme='onehalfdark' " let g:airline_solarized_bg='dark' " }}} " Configure markdown {{{ " let g:vim_markdown_folding_level = 6 let g:vim_markdown_folding_disabled = 1 let g:vim_markdown_new_list_item_indent = 2 let g:markdown_fenced_languages = [ \ 'bash=sh', \ 'c', \ 'javascript', \ 'json', \ 'python', \ 'ruby', \ 'yaml', \ 'swift', \ 'objc' \] " }}} " SuperTab {{{ option for context aware completion let g:SuperTabDefaultCompletionType = "context" " }}} " Clang autocomplete {{{ " Disable auto popup, use to autocomplete let g:clang_complete_auto = 0 " Show clang errors in the quickfix window let g:clang_complete_copen = 1 au CursorMovedI,InsertLeave * if pumvisible() == 0|silent! pclose|endif " }}} " Key mappings {{{ let mapleader = "\" " Change " let maplocalleader = "," " Change " Disable arrow keys nnoremap nnoremap nnoremap nnoremap inoremap inoremap inoremap inoremap nnoremap j gj nnoremap k gk " Better window navigation nnoremap j nnoremap k nnoremap h nnoremap l inoremap nnoremap vnoremap " Use jj to escape inoremap jj nnoremap o :CtrlP " Copy & paste to system clipboard with p and y vmap y "+y " vmap d "+d nmap p "+p nmap P "+P vmap p "+p vmap P "+P " Enter visual line mode with : nmap V " Hit v to select one character " Hit v again to expand selection to word " Hit v again to expand to paragraph vmap v (expand_region_expand) vmap (expand_region_shrink) " Automatically jump to end of text you pasted vnoremap y y`] vnoremap p p`] nnoremap p p`] " Remove all highlightings nnoremap :nohl " quickly insert newline in normalmode without leaving nnoremap ok nnoremap Oj " map ,f to display all lines with keyword under cursor and ask which one to jump to nnoremap f [I:let nr = input("Which one: ")exe "normal " . nr ."[\t" map :NERDTreeToggle " }}} " Special filetypes and encoding {{{ if has('autocmd') "autocmd BufEnter * cd %:p:h filetype plugin indent on endif " }}} " Encoding {{{ " Always check for UTF-8 when trying to determine encodings if &fileencodings !~? "utf-8" set fileencodings+=utf-8 endif " Make sure we have a sane fallback for encoding detection set fileencodings+=default " }}} " Load local vim config {{{ let $LOCALFILE=expand("~/.vimrc_local") if filereadable($LOCALFILE) source $LOCALFILE endif " }}}